Merge branch 'jswain_trial_redirect' into 'master'

Redirect to continuous onboarding after trial reg

See merge request gitlab-org/gitlab!73594
This commit is contained in:
Doug Stull 2021-11-10 00:31:45 +00:00
commit 3a98bb1344
7 changed files with 83 additions and 7 deletions

View file

@ -42,9 +42,14 @@ def create
redirect_to trial_getting_started_users_sign_up_welcome_path(learn_gitlab_project_id: learn_gitlab_project.id)
else
success_url = current_user.setup_for_company ? new_trial_path : nil
success_url = continuous_onboarding_getting_started_users_sign_up_welcome_path(project_id: @project.id)
redirect_to success_url || continuous_onboarding_getting_started_users_sign_up_welcome_path(project_id: @project.id)
if current_user.setup_for_company
store_location_for(:user, success_url)
success_url = new_trial_path
end
redirect_to success_url
end
else
render :new

View file

@ -72,6 +72,10 @@ def extend_reactivate
end
end
def skip
redirect_to stored_location_or_provided_path(dashboard_projects_path)
end
protected
# override the ConfirmEmailWarning method in order to skip
@ -81,6 +85,15 @@ def show_confirm_warning?
private
def stored_location_or_provided_path(path)
if current_user.setup_for_company &&
experiment(:combined_registration, user: current_user).variant.name == 'candidate'
stored_location_for(:user) || path
else
path
end
end
def authenticate_user!
return if current_user
@ -240,7 +253,7 @@ def apply_trial_and_redirect
if discover_group_security_flow?
redirect_trial_user_to_feature_experiment_flow
else
redirect_to group_url(@namespace, { trial: true })
redirect_to stored_location_or_provided_path(group_url(@namespace, { trial: true }))
end
else
render :select

View file

@ -1,9 +1,9 @@
.gl-mt-6{ class: 'gl-md-mt-11!' }
- if params[:glm_source] == 'gitlab.com'
= link_to s_('Trials|Go back to GitLab'), dashboard_projects_path, class: 'block center py-2'
= link_to s_('Trials|Go back to GitLab'), skip_trials_path, class: 'block center py-2'
.label
= s_("Trials|You can always resume this process by selecting your avatar and choosing 'Start an Ultimate trial'")
- else
= link_to s_('Trials|Skip Trial'), dashboard_projects_path, class: 'block center py-2'
= link_to s_('Trials|Skip Trial'), skip_trials_path, class: 'block center py-2'
.label
= s_("Trials|You won't get a free trial right now but you can always resume this process by selecting your avatar and choosing 'Start an Ultimate trial'")

View file

@ -7,5 +7,6 @@
post :apply
put :extend_reactivate
post :create_hand_raise_lead
get :skip
end
end

View file

@ -211,8 +211,10 @@
context 'when the user is setup_for_company: true it redirects to the new_trial_path' do
it_behaves_like "Registrations::ProjectsController POST #create" do
let_it_be(:user) { create(:user, setup_for_company: true) }
let_it_be(:first_project) { create(:project) }
let(:success_path) { new_trial_path }
let(:stored_location_for) { continuous_onboarding_getting_started_users_sign_up_welcome_path(project_id: first_project.id) }
include_context 'groups_projects projects concern'
end

View file

@ -145,6 +145,30 @@
post_create_lead
end
context 'when the user is `setup_for_company: true`' do
let(:user) { create(:user, setup_for_company: true) }
context 'when there is a stored_location_for(:user) set' do
let(:stored_location_for) { continuous_onboarding_getting_started_users_sign_up_welcome_path(project_id: 311) }
before do
controller.store_location_for(:user, stored_location_for)
end
context 'when the user is receiving the combined_registration candidate', :experiment do
before do
stub_experiments(combined_registration: :candidate)
end
it { is_expected.to redirect_to(stored_location_for) }
end
it { is_expected.to redirect_to(group_url(namespace, { trial: true })) }
end
it { is_expected.to redirect_to(group_url(namespace, { trial: true })) }
end
it { is_expected.to redirect_to(group_url(namespace, { trial: true })) }
end
@ -625,4 +649,34 @@
it { is_expected.not_to set_confirm_warning_for(user.email) }
end
end
describe '#skip' do
subject(:get_skip) { get :skip }
context 'when the user is `setup_for_company: true`' do
let(:user) { create(:user, setup_for_company: true) }
it { is_expected.to redirect_to(dashboard_projects_path) }
context 'and has a stored_location_for set' do
before do
controller.store_location_for(:user, new_trial_path)
end
it { is_expected.to redirect_to(dashboard_projects_path) }
context 'when the user is receiving the combined_registration candidate', :experiment do
before do
stub_experiments(combined_registration: :candidate)
end
it { is_expected.to redirect_to(new_trial_path) }
end
end
end
context 'when the user is `setup_for_company: false`' do
it { is_expected.to redirect_to(dashboard_projects_path) }
end
end
end

View file

@ -6,11 +6,13 @@
subject { post :create, params: { project: params }.merge(trial_onboarding_flow_params).merge(extra_params) }
let_it_be(:trial_onboarding_flow_params) { {} }
let_it_be(:first_project) { create(:project) }
let(:params) { { namespace_id: namespace.id, name: 'New project', path: 'project-path', visibility_level: Gitlab::VisibilityLevel::PRIVATE } }
let(:dev_env_or_com) { true }
let(:extra_params) { {} }
let(:success_path) { nil }
let(:stored_location_for) { nil }
context 'with an unauthenticated user' do
it { is_expected.to have_gitlab_http_status(:redirect) }
@ -18,8 +20,6 @@
end
context 'with an authenticated user', :sidekiq_inline do
let_it_be(:first_project) { create(:project) }
before do
namespace.add_owner(user)
sign_in(user)
@ -37,6 +37,7 @@
expect(subject).to have_gitlab_http_status(:redirect)
expect(subject).to redirect_to(success_path || continuous_onboarding_getting_started_users_sign_up_welcome_path(project_id: first_project.id))
expect(controller.stored_location_for(:user)).to eq(stored_location_for)
end
context 'learn gitlab project' do