Skip to content

Commit

Permalink
Merge pull request #582 from splitrb/fix-active-experiments-without-f…
Browse files Browse the repository at this point in the history
…inished-keys

When loading active_experiments, it should not look into user's 'finished' keys
  • Loading branch information
andrehjr authored Aug 26, 2019
2 parents 45de9d0 + 56f1fe9 commit db07b1c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/split/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def cleanup_old_versions!(experiment)

def active_experiments
experiment_pairs = {}
user.keys.each do |key|
keys_without_finished(user.keys).each do |key|
Metric.possible_experiments(key_without_version(key)).each do |experiment|
if !experiment.has_winner?
experiment_pairs[key_without_version(key)] = user[key]
Expand Down
11 changes: 11 additions & 0 deletions spec/helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,17 @@ def should_finish_experiment(experiment_name, should_finish=true)
expect(active_experiments.first[0]).to eq "link_color"
end

it 'should show versioned tests properly' do
10.times { experiment.reset }

alternative = ab_test(experiment.name, 'blue', 'red')
ab_finished(experiment.name, reset: false)

expect(experiment.version).to eq(10)
expect(active_experiments.count).to eq 1
expect(active_experiments).to eq({'link_color' => alternative })
end

it 'should show multiple tests' do
Split.configure do |config|
config.allow_multiple_experiments = true
Expand Down

0 comments on commit db07b1c

Please sign in to comment.