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
6 changes: 6 additions & 0 deletions README.mdown
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ If you have an experiment called `button_color` with alternatives called `red` a

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.

In the event you want to disable all tests without having to know the individual experiment names, add a `SPLIT_DISABLE` query parameter.

http://myawesomesite.com?SPLIT_DISABLE=trues

It is not required to send `SPLIT_DISABLE=false` to activate Split.

### Starting experiments manually

By default new AB tests will be active right after deployment. In case you would like to start new test a while after
Expand Down
12 changes: 10 additions & 2 deletions lib/split/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ def ab_test(metric_descriptor, control=nil, *alternatives)
raise(e) unless Split.configuration.db_failover
Split.configuration.db_failover_on_db_error.call(e)

if Split.configuration.db_failover_allow_parameter_override && override_present?(experiment_name)
ret = override_alternative(experiment_name)
if Split.configuration.db_failover_allow_parameter_override
ret = override_alternative(experiment_name) if override_present?(experiment_name)
ret = control_variable(control) if split_generically_disabled?
end
ensure
ret ||= control_variable(control)
Expand Down Expand Up @@ -97,6 +98,10 @@ def override_alternative(experiment_name)
params[experiment_name] if override_present?(experiment_name)
end

def split_generically_disabled?
defined?(params) && params['SPLIT_DISABLE']
end

def begin_experiment(experiment, alternative_name = nil)
alternative_name ||= experiment.control.name
ab_user[experiment.key] = alternative_name
Expand Down Expand Up @@ -169,6 +174,9 @@ def start_trial(trial)
if override_present?(experiment.name) and experiment[override_alternative(experiment.name)]
ret = override_alternative(experiment.name)
ab_user[experiment.key] = ret if Split.configuration.store_override
elsif split_generically_disabled?
ret = experiment.control.name
ab_user[experiment.key] = ret if Split.configuration.store_override
elsif experiment.has_winner?
ret = experiment.winner.name
else
Expand Down
18 changes: 18 additions & 0 deletions spec/helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,24 @@
ab_test('link_color', 'blue', 'red')
end

it "SPLIT_DISABLE query parameter should also force the alternative (uses control)" do
@params = {'SPLIT_DISABLE' => 'true'}
alternative = ab_test('link_color', 'blue', 'red')
alternative.should eql('blue')
alternative = ab_test('link_color', {'blue' => 1}, 'red' => 5)
alternative.should eql('blue')
alternative = ab_test('link_color', 'red', 'blue')
alternative.should eql('red')
alternative = ab_test('link_color', {'red' => 5}, 'blue' => 1)
alternative.should eql('red')
end

it "should not store the split when Split generically disabled" do
@params = {'SPLIT_DISABLE' => 'true'}
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 }

Expand Down