Skip to content

Commit 3fbf1be

Browse files
sadhu89andrew
authored andcommitted
Do not storage alternative in cookie if experiment has a winner (#539)
1 parent 10289b2 commit 3fbf1be

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/split/trial.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def choose!(context = nil)
8080
end
8181
end
8282

83-
@user[@experiment.key] = alternative.name if should_store_alternative?
83+
@user[@experiment.key] = alternative.name if !@experiment.has_winner? && should_store_alternative?
8484
@alternative_choosen = true
8585
run_callback context, Split.configuration.on_trial unless @options[:disabled] || Split.configuration.disabled?
8686
alternative

spec/trial_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,5 +283,17 @@ def expect_alternative(trial, alternative_name)
283283
trial.choose!
284284
end
285285
end
286+
287+
context 'when experiment has winner' do
288+
let(:trial) do
289+
experiment.winner = 'cart'
290+
Split::Trial.new(:user => user, :experiment => experiment)
291+
end
292+
293+
it 'does not store' do
294+
expect(user).to_not receive("[]=")
295+
trial.choose!
296+
end
297+
end
286298
end
287299
end

0 commit comments

Comments
 (0)