Commit f166ff5b authored by Alex Buijs's avatar Alex Buijs

Add URL parameter to force enable experiments

parent 69362941
...@@ -43,7 +43,7 @@ module Gitlab ...@@ -43,7 +43,7 @@ module Gitlab
end end
def experiment_enabled?(experiment_key) def experiment_enabled?(experiment_key)
Experimentation.enabled_for_user?(experiment_key, experimentation_subject_index) Experimentation.enabled_for_user?(experiment_key, experimentation_subject_index) || forced_enabled?(experiment_key)
end end
def track_experiment_event(experiment_key, action) def track_experiment_event(experiment_key, action)
...@@ -94,6 +94,10 @@ module Gitlab ...@@ -94,6 +94,10 @@ module Gitlab
experiment_enabled?(experiment_key) ? 'experimental_group' : 'control_group' experiment_enabled?(experiment_key) ? 'experimental_group' : 'control_group'
end end
def forced_enabled?(experiment_key)
params.has_key?(:force_experiment) && params[:force_experiment] == experiment_key.to_s
end
end end
class << self class << self
......
...@@ -71,6 +71,24 @@ describe Gitlab::Experimentation do ...@@ -71,6 +71,24 @@ describe Gitlab::Experimentation do
controller.experiment_enabled?(:test_experiment) controller.experiment_enabled?(:test_experiment)
end end
end end
describe 'URL parameter to force enable experiment' do
context 'is not present' do
it 'returns false' do
get :index, params: { force_experiment: :test_experiment2 }
expect(controller.experiment_enabled?(:test_experiment)).to be_falsey
end
end
context 'is present' do
it 'returns true' do
get :index, params: { force_experiment: :test_experiment }
expect(controller.experiment_enabled?(:test_experiment)).to be_truthy
end
end
end
end end
describe '#track_experiment_event' do describe '#track_experiment_event' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment