Commit b16b81b6 authored by Doug Stull's avatar Doug Stull

Merge branch 'jswain_combined_registration_without_force_company_trial' into 'master'

force_trial and combined_registration symbiosis

See merge request gitlab-org/gitlab!69898
parents 170ac699 df6539ec
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
class CombinedRegistrationExperiment < ApplicationExperiment # rubocop:disable Gitlab/NamespacedClass class CombinedRegistrationExperiment < ApplicationExperiment # rubocop:disable Gitlab/NamespacedClass
include Rails.application.routes.url_helpers include Rails.application.routes.url_helpers
def key_for(source, _ = nil)
super(source, 'force_company_trial')
end
def redirect_path(trial_params) def redirect_path(trial_params)
@trial_params = trial_params @trial_params = trial_params
......
...@@ -70,6 +70,8 @@ module EE ...@@ -70,6 +70,8 @@ module EE
override :trial_params override :trial_params
def trial_params def trial_params
return if combined_registration_experiment.variant.name == 'candidate'
experiment(:force_company_trial, user: current_user) do |e| experiment(:force_company_trial, user: current_user) do |e|
e.try { { trial: true } } e.try { { trial: true } }
e.run e.run
...@@ -87,7 +89,11 @@ module EE ...@@ -87,7 +89,11 @@ module EE
end end
def publish_combined_registration_experiment def publish_combined_registration_experiment
experiment(:combined_registration, user: current_user).publish_to_client if show_signup_onboarding? combined_registration_experiment.publish_to_client if show_signup_onboarding?
end
def combined_registration_experiment
experiment(:combined_registration, user: current_user)
end end
end end
end end
......
...@@ -244,17 +244,24 @@ RSpec.describe Registrations::WelcomeController do ...@@ -244,17 +244,24 @@ RSpec.describe Registrations::WelcomeController do
context 'when combined_registration is candidate variant' do context 'when combined_registration is candidate variant' do
before do before do
allow(controller).to receive(:experiment).and_call_original
stub_experiments(combined_registration: :candidate) stub_experiments(combined_registration: :candidate)
end end
it { is_expected.to redirect_to new_users_sign_up_groups_project_path } it { is_expected.to redirect_to new_users_sign_up_groups_project_path }
it "doesn't call the force_company_trial experiment" do
expect(controller).not_to receive(:experiment).with(:force_company_trial, user: user)
subject
end
end end
context 'and force_company_trial experiment is candidate' do context 'and force_company_trial experiment is candidate' do
let(:setup_for_company) { 'true' } let(:setup_for_company) { 'true' }
before do before do
stub_experiments(force_company_trial: :candidate) stub_experiments(combined_registration: :control, force_company_trial: :candidate)
end end
it { is_expected.to redirect_to new_users_sign_up_group_path(trial: true) } it { is_expected.to redirect_to new_users_sign_up_group_path(trial: true) }
......
...@@ -7,6 +7,15 @@ RSpec.describe CombinedRegistrationExperiment, :experiment do ...@@ -7,6 +7,15 @@ RSpec.describe CombinedRegistrationExperiment, :experiment do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
describe '#signature' do
let(:force_company_trial) { experiment(:force_company_trial, user: user) }
it 'returns the same context key for force_company_trial' do
expect(subject.signature[:key]).not_to be_nil
expect(subject.signature[:key]).to eq(force_company_trial.signature[:key])
end
end
describe '#redirect_path' do describe '#redirect_path' do
it 'when control passes trial_params to path' do it 'when control passes trial_params to path' do
stub_experiments(combined_registration: :control) stub_experiments(combined_registration: :control)
......
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