Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.mdown
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ If you have an experiment called `button_color` with alternatives called `red` a

http://myawesomesite.com?button_color=red

will always have red buttons. This won't be stored in your session or count towards to results.
will always have red buttons. This won't be stored in your session or count towards to results, unless you set the `store_override` configuration option.

### Reset after completion

Expand Down
1 change: 1 addition & 0 deletions lib/split/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Configuration
attr_accessor :enabled
attr_accessor :persistence
attr_accessor :algorithm
attr_accessor :store_override

attr_reader :experiments

Expand Down
1 change: 1 addition & 0 deletions lib/split/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ def start_trial(trial)
experiment = trial.experiment
if override_present?(experiment.name)
ret = override_alternative(experiment.name)
ab_user[experiment.key] = ret if Split.configuration.store_override
elsif ! experiment.winner.nil?
ret = experiment.winner.name
else
Expand Down
4 changes: 4 additions & 0 deletions spec/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
@config.disabled?.should be_true
end

it "should not store the overridden test group per default" do
@config.store_override.should be_false
end

it "should provide a default pattern for robots" do
%w[Baidu Gigabot Googlebot libwww-perl lwp-trivial msnbot SiteUptime Slurp WordPress ZIBB ZyBorg YandexBot AdsBot-Google Wget curl bitlybot facebookexternalhit spider].each do |robot|
@config.robot_regex.should =~ robot
Expand Down
16 changes: 16 additions & 0 deletions spec/helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,22 @@
alternative.should eql('red')
end

it "should not store the via params forced alternative" do
@params = {'link_color' => 'blue'}
ab_user.should_not_receive(:[]=)
ab_test('link_color', 'blue', 'red')
end

context "when store_override is set" do
before { Split.configuration.store_override = true }

it "should store the forced alternative" do
@params = {'link_color' => 'blue'}
ab_user.should_receive(:[]=).with('link_color', 'blue')
ab_test('link_color', 'blue', 'red')
end
end

it "should allow passing a block" do
alt = ab_test('link_color', 'blue', 'red')
ret = ab_test('link_color', 'blue', 'red') { |alternative| "shared/#{alternative}" }
Expand Down