Commit a44d81f1 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '328710-trial-during-free-signup-restrict-to-companies' into 'master'

Restrict trial during free signup to company users

See merge request gitlab-org/gitlab!62382
parents f0db5495 26aa54ac
......@@ -16,6 +16,10 @@ module EE
params[:trial_onboarding_flow] == 'true'
end
def show_trial_during_signup?
current_user.setup_for_company
end
def in_trial_during_signup_flow?
params[:trial] == 'true'
end
......
......@@ -41,7 +41,7 @@
.row
.form-group.col-sm-12
= render partial: 'shared/groups/visibility_level', locals: { f: f }
- if !in_trial_onboarding_flow?
- if !in_trial_onboarding_flow? && show_trial_during_signup?
= render partial: 'shared/groups/trial_form'
- else
- experiment(:registrations_group_invite, actor: current_user) do |experiment_instance|
......
......@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe 'User is able to invite members to group during signup', :js, :experiment do
include Select2Helper
let_it_be(:user) { create(:user) }
let_it_be(:user) { create(:user, setup_for_company: true) }
let(:path_params) { {} }
before do
......
......@@ -16,7 +16,7 @@ RSpec.describe 'User sees new onboarding flow', :js do
expect(page).to have_content('Welcome to GitLab')
choose 'Just me'
choose 'My company or team'
click_on 'Continue'
expect(page).to have_content('GitLab Ultimate trial (optional)')
......
......@@ -37,6 +37,25 @@ RSpec.describe EE::WelcomeHelper do
end
end
describe '#show_trial_during_signup?' do
before do
allow(helper).to receive(:current_user).and_return(user)
end
where(:setup_for_company, :expected_result) do
true | true
false | false
end
with_them do
let(:user) { create(:user, setup_for_company: setup_for_company) }
it 'returns the expected_result' do
expect(helper.show_trial_during_signup?).to eq(expected_result)
end
end
end
describe '#in_oauth_flow?' do
where(:user_return_to_path, :expected_result) do
'/oauth/authorize?client_id=x&redirect_uri=y&response_type=code&state=z' | true
......
......@@ -6,11 +6,13 @@ RSpec.describe 'registrations/groups/new' do
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) }
let_it_be(:trial_onboarding_flow) { false }
let_it_be(:show_trial_during_signup) { true }
before do
assign(:group, group)
allow(view).to receive(:current_user).and_return(user)
allow(view).to receive(:in_trial_onboarding_flow?).and_return(trial_onboarding_flow)
allow(view).to receive(:show_trial_during_signup?).and_return(show_trial_during_signup)
render
end
......@@ -26,6 +28,10 @@ RSpec.describe 'registrations/groups/new' do
expect(rendered).to have_selector('#progress-bar')
end
it 'shows the trial during signup form' do
expect(rendered).to have_content('GitLab Ultimate trial (optional)')
end
context 'in trial onboarding' do
let_it_be(:trial_onboarding_flow) { true }
......@@ -38,4 +44,12 @@ RSpec.describe 'registrations/groups/new' do
expect(rendered).not_to have_selector('#progress-bar')
end
end
context 'not showing trial during signup' do
let_it_be(:show_trial_during_signup) { false }
it 'shows the trial during signup form' do
expect(rendered).not_to have_content('GitLab Ultimate trial (optional)')
end
end
end
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