Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added option to finished to not reset the users session

  • Loading branch information...
commit d94ffb2d5bc15ed418f6275f82d342de953cf4d1 1 parent 6276065
@andrew andrew authored
Showing with 13 additions and 2 deletions.
  1. +2 −2 lib/split/helper.rb
  2. +11 −0 spec/helper_spec.rb
View
4 lib/split/helper.rb
@@ -34,13 +34,13 @@ def ab_test(experiment_name, *alternatives)
end
end
- def finished(experiment_name)
+ def finished(experiment_name, options = {:reset => true})
return if exclude_visitor?
experiment = Split::Experiment.find(experiment_name)
if alternative_name = ab_user[experiment.key]
alternative = Split::Alternative.find(alternative_name, experiment_name)
alternative.increment_completion
- session[:split].delete(experiment_name)
+ session[:split].delete(experiment_name) if options[:reset]
end
end
View
11 spec/helper_spec.rb
@@ -83,6 +83,17 @@
finished('link_color')
session[:split].should == {}
end
+
+ it "should not clear out the users session if reset is false" do
+ experiment = Split::Experiment.find_or_create('link_color', 'blue', 'red')
+ alternative_name = ab_test('link_color', 'blue', 'red')
+
+ previous_completion_count = Split::Alternative.find(alternative_name, 'link_color').completed_count
+
+ session[:split].should eql("link_color" => alternative_name)
+ finished('link_color', :reset => false)
+ session[:split].should eql("link_color" => alternative_name)
+ end
end
describe 'conversions' do
Please sign in to comment.
Something went wrong with that request. Please try again.