Commit 7c4bc9d1 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'growth-77-force-enable-experimental-group' into 'master'

Force enable experimental group for growth experiments

Closes gitlab-org/growth/engineering#77

See merge request gitlab-org/gitlab!18872
parents bbf5faea f166ff5b
...@@ -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