File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -68,10 +68,8 @@ def choose!(context = nil)
6868 if exclude_user?
6969 self . alternative = @experiment . control
7070 else
71- value = @user [ @experiment . key ]
72- if value
73- self . alternative = value
74- else
71+ self . alternative = @user [ @experiment . key ]
72+ if alternative . nil?
7573 self . alternative = @experiment . next_alternative
7674
7775 # Increment the number of participants since we are actually choosing a new alternative
Original file line number Diff line number Diff line change @@ -176,6 +176,14 @@ def expect_alternative(trial, alternative_name)
176176
177177 expect_alternative ( trial , 'basket' )
178178 end
179+
180+ context "when alternative is not found" do
181+ it "falls back on next_alternative" do
182+ user [ experiment . key ] = 'notfound'
183+ expect ( experiment ) . to receive ( :next_alternative ) . and_call_original
184+ expect_alternative ( trial , alternatives )
185+ end
186+ end
179187 end
180188
181189 context "when user is a new participant" do
You can’t perform that action at this time.
0 commit comments