Commit d48f786d authored by Jay Swain's avatar Jay Swain

Redirect to continuous onboarding after trial reg

* added a skip action to ensure that we're clearing the stored location
  for user

part of:
https://gitlab.com/gitlab-org/gitlab/-/issues/343923

Changelog: changed
MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/73594
EE: true
parent 754e23a2
......@@ -42,9 +42,14 @@ module Registrations
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
......
......@@ -72,6 +72,10 @@ class TrialsController < ApplicationController
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 @@ class TrialsController < ApplicationController
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 @@ class TrialsController < ApplicationController
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
......
.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'")
......@@ -7,5 +7,6 @@ resources :trials, only: [:new] do
post :apply
put :extend_reactivate
post :create_hand_raise_lead
get :skip
end
end
......@@ -211,8 +211,10 @@ RSpec.describe Registrations::GroupsProjectsController, :experiment do
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
......
......@@ -145,6 +145,30 @@ RSpec.describe TrialsController, :saas do
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 @@ RSpec.describe TrialsController, :saas do
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
......@@ -6,11 +6,13 @@ RSpec.shared_examples "Registrations::ProjectsController POST #create" do
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 @@ RSpec.shared_examples "Registrations::ProjectsController POST #create" do
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 @@ RSpec.shared_examples "Registrations::ProjectsController POST #create" do
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
......
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