Commit 9fef92d3 authored by Doug Stull's avatar Doug Stull

Commit registration invite page to product

- for .com only - experiment passed.

Changelog: added
parent fa597211
...@@ -4,6 +4,7 @@ module Registrations ...@@ -4,6 +4,7 @@ module Registrations
class GroupInvitesController < Groups::ApplicationController class GroupInvitesController < Groups::ApplicationController
layout 'checkout' layout 'checkout'
before_action :check_if_gl_com_or_dev
before_action :authorize_invite_to_group! before_action :authorize_invite_to_group!
feature_category :navigation feature_category :navigation
...@@ -12,12 +13,7 @@ module Registrations ...@@ -12,12 +13,7 @@ module Registrations
end end
def create def create
result = Members::CreateService.new(current_user, invite_params).execute Members::CreateService.new(current_user, invite_params).execute
if result[:status] == :success
experiment(:registrations_group_invite, actor: current_user)
.track(:invites_sent, property: group.id.to_s, value: group.members.invite.size)
end
redirect_to new_users_sign_up_project_path(namespace_id: group.id, redirect_to new_users_sign_up_project_path(namespace_id: group.id,
trial: helpers.in_trial_during_signup_flow?, trial: helpers.in_trial_during_signup_flow?,
......
...@@ -6,7 +6,7 @@ module Registrations ...@@ -6,7 +6,7 @@ module Registrations
layout 'checkout' layout 'checkout'
before_action :check_signup_onboarding_enabled before_action :check_if_gl_com_or_dev
before_action :authorize_create_group!, only: :new before_action :authorize_create_group!, only: :new
feature_category :onboarding feature_category :onboarding
...@@ -37,10 +37,6 @@ module Registrations ...@@ -37,10 +37,6 @@ module Registrations
private private
def check_signup_onboarding_enabled
access_denied! unless helpers.signup_onboarding_enabled?
end
def create_successful_flow def create_successful_flow
if helpers.in_trial_onboarding_flow? if helpers.in_trial_onboarding_flow?
apply_trial_for_trial_onboarding_flow apply_trial_for_trial_onboarding_flow
...@@ -64,7 +60,7 @@ module Registrations ...@@ -64,7 +60,7 @@ module Registrations
record_experiment_conversion_event(:remove_known_trial_form_fields) record_experiment_conversion_event(:remove_known_trial_form_fields)
record_experiment_conversion_event(:trial_onboarding_issues) record_experiment_conversion_event(:trial_onboarding_issues)
registrations_group_invite_flow(trial_onboarding_flow: true) redirect_to new_users_sign_up_group_invite_path(group_id: @group.id, trial: helpers.in_trial_during_signup_flow?, trial_onboarding_flow: true)
else else
render action: :new render action: :new
end end
...@@ -74,26 +70,18 @@ module Registrations ...@@ -74,26 +70,18 @@ module Registrations
record_experiment_conversion_event(:learn_gitlab_a, namespace_id: @group.id) record_experiment_conversion_event(:learn_gitlab_a, namespace_id: @group.id)
record_experiment_conversion_event(:learn_gitlab_b, namespace_id: @group.id) record_experiment_conversion_event(:learn_gitlab_b, namespace_id: @group.id)
create_lead_and_apply_trial_flow
end
def create_lead_and_apply_trial_flow
if helpers.in_trial_during_signup_flow? if helpers.in_trial_during_signup_flow?
if create_lead && apply_trial create_lead_and_apply_trial_flow
registrations_group_invite_flow
else
render action: :new
end
else else
registrations_group_invite_flow redirect_to new_users_sign_up_group_invite_path(group_id: @group.id, trial: false)
end end
end end
def registrations_group_invite_flow(options = {}) def create_lead_and_apply_trial_flow
experiment(:registrations_group_invite, actor: current_user) do |experiment_instance| if create_lead && apply_trial
experiment_instance.use { redirect_to new_users_sign_up_project_path({ namespace_id: @group.id, trial: helpers.in_trial_during_signup_flow? }.merge(options) ) } # control redirect_to new_users_sign_up_group_invite_path(group_id: @group.id, trial: true)
experiment_instance.try(:invite_page) { redirect_to new_users_sign_up_group_invite_path({ group_id: @group.id, trial: helpers.in_trial_during_signup_flow? }.merge(options)) } # with separate page else
experiment_instance.track(:created, property: @group.id.to_s) render action: :new
end end
end end
......
...@@ -8,7 +8,7 @@ module Registrations ...@@ -8,7 +8,7 @@ module Registrations
LEARN_GITLAB_TEMPLATE = 'learn_gitlab.tar.gz' LEARN_GITLAB_TEMPLATE = 'learn_gitlab.tar.gz'
LEARN_GITLAB_ULTIMATE_TEMPLATE = 'learn_gitlab_ultimate_trial.tar.gz' LEARN_GITLAB_ULTIMATE_TEMPLATE = 'learn_gitlab_ultimate_trial.tar.gz'
before_action :check_signup_onboarding_enabled before_action :check_if_gl_com_or_dev
before_action only: [:new] do before_action only: [:new] do
set_namespace set_namespace
authorize_create_project! authorize_create_project!
...@@ -31,8 +31,6 @@ module Registrations ...@@ -31,8 +31,6 @@ module Registrations
learn_gitlab_project_id: learn_gitlab_project.id learn_gitlab_project_id: learn_gitlab_project.id
} }
experiment(:registrations_group_invite, actor: current_user)
.track(:signup_successful, property: @project.namespace_id.to_s)
experiment(:jobs_to_be_done, user: current_user) experiment(:jobs_to_be_done, user: current_user)
.track(:create_project, project: @project) .track(:create_project, project: @project)
...@@ -58,10 +56,6 @@ module Registrations ...@@ -58,10 +56,6 @@ module Registrations
private private
def check_signup_onboarding_enabled
access_denied! unless helpers.signup_onboarding_enabled?
end
def create_learn_gitlab_project def create_learn_gitlab_project
File.open(learn_gitlab_template_path) do |archive| File.open(learn_gitlab_template_path) do |archive|
::Projects::GitlabProjectsImportService.new( ::Projects::GitlabProjectsImportService.new(
......
...@@ -43,11 +43,7 @@ ...@@ -43,11 +43,7 @@
= render partial: 'shared/groups/visibility_level', locals: { f: f } = render partial: 'shared/groups/visibility_level', locals: { f: f }
- if !in_trial_onboarding_flow? && show_trial_during_signup? - if !in_trial_onboarding_flow? && show_trial_during_signup?
= render partial: 'shared/groups/trial_form' = render partial: 'shared/groups/trial_form'
- else
- experiment(:registrations_group_invite, actor: current_user) do |experiment_instance|
- experiment_instance.use do
= render partial: 'shared/groups/invite_members'
- experiment_instance.try(:invite_page) {}
.row .row
.form-group.col-sm-12.gl-mb-0 .form-group.col-sm-12.gl-mb-0
= button_tag class: %w[btn gl-button btn-success gl-w-full!] do = button_tag class: %w[btn gl-button btn-success gl-w-full!] do
......
---
name: registrations_group_invite
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/52371
rollout_issue_url: https://gitlab.com/gitlab-org/growth/team-tasks/-/issues/351
milestone: '13.10'
type: experiment
group: group::expansion
default_enabled: false
...@@ -28,7 +28,7 @@ RSpec.describe Registrations::GroupsController do ...@@ -28,7 +28,7 @@ RSpec.describe Registrations::GroupsController do
end end
describe 'GET #new', :aggregate_failures do describe 'GET #new', :aggregate_failures do
let(:signup_onboarding_enabled) { true } let(:dev_env_or_com) { true }
let(:learn_gitlab_context) do let(:learn_gitlab_context) do
{ {
in_experiment_group_a: false, in_experiment_group_a: false,
...@@ -46,49 +46,51 @@ RSpec.describe Registrations::GroupsController do ...@@ -46,49 +46,51 @@ RSpec.describe Registrations::GroupsController do
context 'with an authenticated user' do context 'with an authenticated user' do
before do before do
sign_in(user) sign_in(user)
allow(controller.helpers).to receive(:signup_onboarding_enabled?).and_return(signup_onboarding_enabled) allow(::Gitlab).to receive(:dev_env_or_com?).and_return(dev_env_or_com)
end end
it { is_expected.to have_gitlab_http_status(:ok) } context 'when on .com' do
it { is_expected.to render_template(:new) } it { is_expected.to have_gitlab_http_status(:ok) }
it { is_expected.to render_template(:new) }
it 'assigns the group variable to a new Group with the default group visibility' do
subject
expect(assigns(:group)).to be_a_new(Group)
expect(assigns(:group).visibility_level).to eq(Gitlab::CurrentSettings.default_group_visibility) it 'assigns the group variable to a new Group with the default group visibility' do
end subject
expect(assigns(:group)).to be_a_new(Group)
context 'with different experiment rollouts' do expect(assigns(:group).visibility_level).to eq(Gitlab::CurrentSettings.default_group_visibility)
before do
stub_experiment_for_subject(learn_gitlab_a: experiment_a, learn_gitlab_b: experiment_b)
end end
where(:experiment_a, :experiment_b, :context) do context 'with different experiment rollouts' do
false | false | { in_experiment_group_a: false, in_experiment_group_b: false } before do
false | true | { in_experiment_group_a: false, in_experiment_group_b: true } stub_experiment_for_subject(learn_gitlab_a: experiment_a, learn_gitlab_b: experiment_b)
true | false | { in_experiment_group_a: true, in_experiment_group_b: false } end
true | true | { in_experiment_group_a: true, in_experiment_group_b: false }
end
with_them do where(:experiment_a, :experiment_b, :context) do
it 'sets the correct context', :aggregate_failures do false | false | { in_experiment_group_a: false, in_experiment_group_b: false }
expect(controller).to receive(:record_experiment_user).with(:learn_gitlab_a, context) false | true | { in_experiment_group_a: false, in_experiment_group_b: true }
expect(controller).to receive(:record_experiment_user).with(:learn_gitlab_b, context) true | false | { in_experiment_group_a: true, in_experiment_group_b: false }
true | true | { in_experiment_group_a: true, in_experiment_group_b: false }
end
subject with_them do
it 'sets the correct context', :aggregate_failures do
expect(controller).to receive(:record_experiment_user).with(:learn_gitlab_a, context)
expect(controller).to receive(:record_experiment_user).with(:learn_gitlab_b, context)
subject
end
end end
end end
end
context 'user without the ability to create a group' do context 'user without the ability to create a group' do
let(:user) { create(:user, can_create_group: false) } let(:user) { create(:user, can_create_group: false) }
it { is_expected.to have_gitlab_http_status(:not_found) } it { is_expected.to have_gitlab_http_status(:not_found) }
end
end end
context 'signup onboarding not enabled' do context 'when not on .com' do
let(:signup_onboarding_enabled) { false } let(:dev_env_or_com) { false }
it { is_expected.to have_gitlab_http_status(:not_found) } it { is_expected.to have_gitlab_http_status(:not_found) }
end end
...@@ -103,7 +105,7 @@ RSpec.describe Registrations::GroupsController do ...@@ -103,7 +105,7 @@ RSpec.describe Registrations::GroupsController do
let_it_be(:trial_onboarding_issues_enabled) { false } let_it_be(:trial_onboarding_issues_enabled) { false }
let_it_be(:trial_onboarding_flow_params) { {} } let_it_be(:trial_onboarding_flow_params) { {} }
let(:signup_onboarding_enabled) { true } let(:dev_env_or_com) { true }
let(:group_params) { { name: 'Group name', path: 'group-path', visibility_level: Gitlab::VisibilityLevel::PRIVATE, emails: ['', ''] } } let(:group_params) { { name: 'Group name', path: 'group-path', visibility_level: Gitlab::VisibilityLevel::PRIVATE, emails: ['', ''] } }
let(:params) do let(:params) do
{ group: group_params }.merge(glm_params).merge(trial_form_params).merge(trial_onboarding_flow_params) { group: group_params }.merge(glm_params).merge(trial_form_params).merge(trial_onboarding_flow_params)
...@@ -120,282 +122,218 @@ RSpec.describe Registrations::GroupsController do ...@@ -120,282 +122,218 @@ RSpec.describe Registrations::GroupsController do
before do before do
sign_in(user) sign_in(user)
stub_experiment_for_subject(trial_onboarding_issues: trial_onboarding_issues_enabled) stub_experiment_for_subject(trial_onboarding_issues: trial_onboarding_issues_enabled)
allow(controller.helpers).to receive(:signup_onboarding_enabled?).and_return(signup_onboarding_enabled) allow(::Gitlab).to receive(:dev_env_or_com?).and_return(dev_env_or_com)
end end
it_behaves_like 'hides email confirmation warning' context 'when on .com' do
it_behaves_like 'hides email confirmation warning'
context 'when signup onboarding is not enabled' do
let(:signup_onboarding_enabled) { false }
it { is_expected.to have_gitlab_http_status(:not_found) } context 'when group can be created' do
end it 'creates a group' do
expect { subject }.to change { Group.count }.by(1)
context 'when group can be created' do end
it 'creates a group' do
expect { subject }.to change { Group.count }.by(1)
end
it 'tracks an event for the jobs_to_be_done experiment', :experiment do it 'tracks an event for the jobs_to_be_done experiment', :experiment do
stub_experiments(jobs_to_be_done: :candidate) stub_experiments(jobs_to_be_done: :candidate)
expect(experiment(:jobs_to_be_done)).to track(:create_group, namespace: an_instance_of(Group)) expect(experiment(:jobs_to_be_done)).to track(:create_group, namespace: an_instance_of(Group))
.on_next_instance .on_next_instance
.for(:candidate) .for(:candidate)
.with_context(user: user) .with_context(user: user)
subject subject
end
context 'when the trial onboarding is active - apply_trial_for_trial_onboarding_flow' do
let_it_be(:group) { create(:group) }
let_it_be(:trial_onboarding_flow_params) { { trial_onboarding_flow: true, glm_source: 'about.gitlab.com', glm_content: 'content' } }
let_it_be(:trial_onboarding_issues_enabled) { true }
let_it_be(:apply_trial_params) do
{
uid: user.id,
trial_user: ActionController::Parameters.new(
{
glm_source: 'about.gitlab.com',
glm_content: 'content',
namespace_id: group.id,
gitlab_com_trial: true,
sync_to_gl: true
}
).permit!
}
end end
before do context 'when the trial onboarding is active - apply_trial_for_trial_onboarding_flow' do
expect_next_instance_of(::Groups::CreateService) do |service| let_it_be(:group) { create(:group) }
expect(service).to receive(:execute).and_return(group) let_it_be(:trial_onboarding_flow_params) { { trial_onboarding_flow: true, glm_source: 'about.gitlab.com', glm_content: 'content' } }
let_it_be(:trial_onboarding_issues_enabled) { true }
let_it_be(:apply_trial_params) do
{
uid: user.id,
trial_user: ActionController::Parameters.new(
{
glm_source: 'about.gitlab.com',
glm_content: 'content',
namespace_id: group.id,
gitlab_com_trial: true,
sync_to_gl: true
}
).permit!
}
end end
end
context 'when trial can be applied' do
before do before do
expect_next_instance_of(GitlabSubscriptions::ApplyTrialService) do |service| expect_next_instance_of(::Groups::CreateService) do |service|
expect(service).to receive(:execute).with(apply_trial_params).and_return({ success: true }) expect(service).to receive(:execute).and_return(group)
end end
expect(controller).to receive(:record_experiment_user).with(:remove_known_trial_form_fields, namespace_id: group.id)
expect(controller).to receive(:record_experiment_user).with(:trial_onboarding_issues, namespace_id: group.id)
expect(controller).to receive(:record_experiment_conversion_event).with(:remove_known_trial_form_fields)
expect(controller).to receive(:record_experiment_conversion_event).with(:trial_onboarding_issues)
end end
context 'when registration_group_invite experiment is enabled' do context 'when trial can be applied' do
before do before do
stub_experiments(registrations_group_invite: :invite_page) expect_next_instance_of(GitlabSubscriptions::ApplyTrialService) do |service|
expect(service).to receive(:execute).with(apply_trial_params).and_return({ success: true })
end
expect(controller).to receive(:record_experiment_user).with(:remove_known_trial_form_fields, namespace_id: group.id)
expect(controller).to receive(:record_experiment_user).with(:trial_onboarding_issues, namespace_id: group.id)
expect(controller).to receive(:record_experiment_conversion_event).with(:remove_known_trial_form_fields)
expect(controller).to receive(:record_experiment_conversion_event).with(:trial_onboarding_issues)
end end
it { is_expected.to redirect_to(new_users_sign_up_group_invite_path(group_id: group.id, trial: false, trial_onboarding_flow: true)) } context 'with separate invite page' do
it { is_expected.to redirect_to(new_users_sign_up_group_invite_path(group_id: group.id, trial: false, trial_onboarding_flow: true)) }
end
end end
context 'when registration_group_invite experiment is disabled' do context 'when failing to apply trial' do
before do before do
stub_experiments(registrations_group_invite: :control) expect_next_instance_of(GitlabSubscriptions::ApplyTrialService) do |service|
expect(service).to receive(:execute).with(apply_trial_params).and_return({ success: false })
end
end end
it { is_expected.to redirect_to(new_users_sign_up_project_path(namespace_id: group.id, trial: false, trial_onboarding_flow: true)) } it { is_expected.to render_template(:new) }
end end
end end
context 'when failing to apply trial' do context 'when not in the trial onboarding - registration_onboarding_flow' do
before do let_it_be(:group) { create(:group) }
expect_next_instance_of(GitlabSubscriptions::ApplyTrialService) do |service|
expect(service).to receive(:execute).with(apply_trial_params).and_return({ success: false })
end
end
it { is_expected.to render_template(:new) }
end
end
context 'when not in the trial onboarding - registration_onboarding_flow' do it 'calls the record user for learn gitlab experiment' do
let_it_be(:group) { create(:group) } expect_next_instance_of(Groups::CreateService) do |service|
expect(service).to receive(:execute).and_return(group)
it 'calls the record user for learn gitlab experiment' do end
expect_next_instance_of(Groups::CreateService) do |service| expect(controller).to receive(:record_experiment_conversion_event).with(:learn_gitlab_a, namespace_id: group.id)
expect(service).to receive(:execute).and_return(group) expect(controller).to receive(:record_experiment_conversion_event).with(:learn_gitlab_b, namespace_id: group.id)
end
expect(controller).to receive(:record_experiment_conversion_event).with(:learn_gitlab_a, namespace_id: group.id)
expect(controller).to receive(:record_experiment_conversion_event).with(:learn_gitlab_b, namespace_id: group.id)
subject
end
context 'when trial_during_signup - trial_during_signup_flow' do
let_it_be(:glm_params) { { glm_source: 'gitlab.com', glm_content: 'content' } }
let_it_be(:trial_form_params) do
{
trial: 'true',
company_name: 'ACME',
company_size: '1-99',
phone_number: '11111111',
number_of_users: '17',
country: 'Norway'
}
end
let_it_be(:trial_user_params) do
{
work_email: user.email,
first_name: user.first_name,
last_name: user.last_name,
uid: user.id,
skip_email_confirmation: true,
gitlab_com_trial: true,
provider: 'gitlab',
newsletter_segment: user.email_opted_in
}
end
let_it_be(:trial_params) do subject
{
trial_user: ActionController::Parameters.new(trial_form_params.except(:trial).merge(trial_user_params)).permit!
}
end end
let_it_be(:apply_trial_params) do context 'when trial_during_signup - trial_during_signup_flow' do
{ let_it_be(:glm_params) { { glm_source: 'gitlab.com', glm_content: 'content' } }
uid: user.id, let_it_be(:trial_form_params) do
trial_user: ActionController::Parameters.new( {
{ trial: 'true',
glm_source: 'gitlab.com', company_name: 'ACME',
glm_content: 'content', company_size: '1-99',
namespace_id: group.id, phone_number: '11111111',
gitlab_com_trial: true, number_of_users: '17',
sync_to_gl: true country: 'Norway'
} }
).permit! end
}
end
context 'when a user chooses a trial - create_lead_and_apply_trial_flow' do let_it_be(:trial_user_params) do
context 'when successfully creating a lead and applying trial' do {
before do work_email: user.email,
expect_next_instance_of(Groups::CreateService) do |service| first_name: user.first_name,
expect(service).to receive(:execute).and_return(group) last_name: user.last_name,
end uid: user.id,
expect_next_instance_of(GitlabSubscriptions::CreateLeadService) do |service| skip_email_confirmation: true,
expect(service).to receive(:execute).with(trial_params).and_return(success: true) gitlab_com_trial: true,
end provider: 'gitlab',
expect_next_instance_of(GitlabSubscriptions::ApplyTrialService) do |service| newsletter_segment: user.email_opted_in
expect(service).to receive(:execute).with(apply_trial_params).and_return({ success: true }) }
end end
end
context 'with registrations_group_invite experiment' do let_it_be(:trial_params) do
it 'tracks experiment as expected', :experiment do {
expect(experiment(:registrations_group_invite)) trial_user: ActionController::Parameters.new(trial_form_params.except(:trial).merge(trial_user_params)).permit!
.to track(:created, { property: group.id.to_s }) }
.on_next_instance end
.with_context(actor: user)
subject let_it_be(:apply_trial_params) do
end {
uid: user.id,
trial_user: ActionController::Parameters.new(
{
glm_source: 'gitlab.com',
glm_content: 'content',
namespace_id: group.id,
gitlab_com_trial: true,
sync_to_gl: true
}
).permit!
}
end
context 'when registrations_group_invite invite_page path is taken' do context 'when a user chooses a trial - create_lead_and_apply_trial_flow' do
before do context 'when successfully creating a lead and applying trial' do
stub_experiments(registrations_group_invite: :invite_page) before do
expect_next_instance_of(Groups::CreateService) do |service|
expect(service).to receive(:execute).and_return(group)
end end
expect_next_instance_of(GitlabSubscriptions::CreateLeadService) do |service|
it { is_expected.to redirect_to(new_users_sign_up_group_invite_path(group_id: group.id, trial: true)) } expect(service).to receive(:execute).with(trial_params).and_return(success: true)
end end
expect_next_instance_of(GitlabSubscriptions::ApplyTrialService) do |service|
context 'when registrations_group_invite experiment control path is taken' do expect(service).to receive(:execute).with(apply_trial_params).and_return({ success: true })
before do
stub_experiments(registrations_group_invite: :control)
end end
it { is_expected.to redirect_to(new_users_sign_up_project_path(namespace_id: group.id, trial: true)) }
end end
end
end
context 'when failing to create a lead and apply trial' do context 'with separate invite page' do
before do it { is_expected.to redirect_to(new_users_sign_up_group_invite_path(group_id: group.id, trial: true)) }
expect_next_instance_of(Groups::CreateService) do |service|
expect(service).to receive(:execute).and_return(group)
end
expect_next_instance_of(GitlabSubscriptions::CreateLeadService) do |service|
expect(service).to receive(:execute).with(trial_params).and_return(success: false)
end end
end end
it { is_expected.to render_template(:new) } context 'when failing to create a lead and apply trial' do
end before do
end expect_next_instance_of(Groups::CreateService) do |service|
expect(service).to receive(:execute).and_return(group)
context 'when user chooses no trial' do end
let_it_be(:trial_form_params) { { trial: 'false' } } expect_next_instance_of(GitlabSubscriptions::CreateLeadService) do |service|
expect(service).to receive(:execute).with(trial_params).and_return(success: false)
end
end
it 'redirects user to the new user signup page' do it { is_expected.to render_template(:new) }
expect_next_instance_of(Groups::CreateService) do |service|
expect(service).to receive(:execute).and_return(group)
end end
expect(subject).to redirect_to(new_users_sign_up_project_path(namespace_id: group.id, trial: false))
end end
it 'does not call trial creation methods' do context 'when user chooses no trial' do
expect(controller).not_to receive(:create_lead) let_it_be(:trial_form_params) { { trial: 'false' } }
expect(controller).not_to receive(:apply_trial)
subject
end
context 'with registrations_group_invite experiment' do it 'redirects user to a separate invite page' do
it 'tracks experiment as expected', :experiment do
expect_next_instance_of(Groups::CreateService) do |service| expect_next_instance_of(Groups::CreateService) do |service|
expect(service).to receive(:execute).and_return(group) expect(service).to receive(:execute).and_return(group)
end end
expect(experiment(:registrations_group_invite)) expect(subject).to redirect_to(new_users_sign_up_group_invite_path(group_id: group.id, trial: false))
.to track(:created, { property: group.id.to_s })
.on_next_instance
.with_context(actor: user)
subject
end
context 'when registrations_group_invite invite_page path is taken' do
before do
stub_experiments(registrations_group_invite: :invite_page)
end
it { is_expected.to redirect_to(new_users_sign_up_group_invite_path(group_id: user.groups.last.id, trial: false)) }
end end
context 'when registrations_group_invite experiment control path is taken' do it 'does not call trial creation methods' do
before do expect(controller).not_to receive(:create_lead)
stub_experiments(registrations_group_invite: :control) expect(controller).not_to receive(:apply_trial)
end
it { is_expected.to redirect_to(new_users_sign_up_project_path(namespace_id: user.groups.last.id, trial: false)) } subject
end end
end end
end end
end end
end end
end
context 'when the group cannot be created' do context 'when the group cannot be created' do
let(:group_params) { { name: '', path: '' } } let(:group_params) { { name: '', path: '' } }
it 'does not create a group', :aggregate_failures do it 'does not create a group', :aggregate_failures do
expect { subject }.not_to change { Group.count } expect { subject }.not_to change { Group.count }
expect(assigns(:group).errors).not_to be_blank expect(assigns(:group).errors).not_to be_blank
end end
it 'does not call call the successful flow' do it 'does not call call the successful flow' do
expect(controller).not_to receive(:create_successful_flow) expect(controller).not_to receive(:create_successful_flow)
subject subject
end
it { is_expected.to have_gitlab_http_status(:ok) }
it { is_expected.to render_template(:new) }
end end
end
it { is_expected.to have_gitlab_http_status(:ok) } context 'when not on .com' do
it { is_expected.to render_template(:new) } let(:dev_env_or_com) { false }
it { is_expected.to have_gitlab_http_status(:not_found) }
end end
end end
end end
......
...@@ -18,32 +18,34 @@ RSpec.describe Registrations::ProjectsController do ...@@ -18,32 +18,34 @@ RSpec.describe Registrations::ProjectsController do
end end
context 'with an authenticated user' do context 'with an authenticated user' do
let(:signup_onboarding_enabled) { true } let(:dev_env_or_com) { true }
before do before do
sign_in(user) sign_in(user)
allow(controller.helpers).to receive(:signup_onboarding_enabled?).and_return(signup_onboarding_enabled) allow(::Gitlab).to receive(:dev_env_or_com?).and_return(dev_env_or_com)
end end
it { is_expected.to have_gitlab_http_status(:not_found) } context 'when on .com' do
it { is_expected.to have_gitlab_http_status(:not_found) }
context 'with a namespace in the URL' do context 'with a namespace in the URL' do
subject { get :new, params: { namespace_id: namespace.id } } subject { get :new, params: { namespace_id: namespace.id } }
it { is_expected.to have_gitlab_http_status(:not_found) } it { is_expected.to have_gitlab_http_status(:not_found) }
context 'with sufficient access' do context 'with sufficient access' do
before do before do
namespace.add_owner(user) namespace.add_owner(user)
end end
it { is_expected.to have_gitlab_http_status(:ok) } it { is_expected.to have_gitlab_http_status(:ok) }
it { is_expected.to render_template(:new) } it { is_expected.to render_template(:new) }
end
end end
end end
context 'with signup onboarding not enabled' do context 'when not on .com' do
let(:signup_onboarding_enabled) { false } let(:dev_env_or_com) { false }
it { is_expected.to have_gitlab_http_status(:not_found) } it { is_expected.to have_gitlab_http_status(:not_found) }
end end
...@@ -56,7 +58,7 @@ RSpec.describe Registrations::ProjectsController do ...@@ -56,7 +58,7 @@ RSpec.describe Registrations::ProjectsController do
let_it_be(:trial_onboarding_flow_params) { {} } let_it_be(:trial_onboarding_flow_params) { {} }
let(:params) { { namespace_id: namespace.id, name: 'New project', path: 'project-path', visibility_level: Gitlab::VisibilityLevel::PRIVATE } } let(:params) { { namespace_id: namespace.id, name: 'New project', path: 'project-path', visibility_level: Gitlab::VisibilityLevel::PRIVATE } }
let(:signup_onboarding_enabled) { true } let(:dev_env_or_com) { true }
context 'with an unauthenticated user' do context 'with an unauthenticated user' do
it { is_expected.to have_gitlab_http_status(:redirect) } it { is_expected.to have_gitlab_http_status(:redirect) }
...@@ -74,7 +76,7 @@ RSpec.describe Registrations::ProjectsController do ...@@ -74,7 +76,7 @@ RSpec.describe Registrations::ProjectsController do
namespace.add_owner(user) namespace.add_owner(user)
sign_in(user) sign_in(user)
stub_experiment_for_subject(trial_onboarding_issues: trial_onboarding_issues_enabled) stub_experiment_for_subject(trial_onboarding_issues: trial_onboarding_issues_enabled)
allow(controller.helpers).to receive(:signup_onboarding_enabled?).and_return(signup_onboarding_enabled) allow(::Gitlab).to receive(:dev_env_or_com?).and_return(dev_env_or_com)
end end
it 'creates a new project, a "Learn GitLab" project, sets a cookie and redirects to the experience level page' do it 'creates a new project, a "Learn GitLab" project, sets a cookie and redirects to the experience level page' do
...@@ -108,15 +110,6 @@ RSpec.describe Registrations::ProjectsController do ...@@ -108,15 +110,6 @@ RSpec.describe Registrations::ProjectsController do
subject subject
end end
it 'tracks the registrations_group_invite experiment as expected', :experiment do
expect(experiment(:registrations_group_invite))
.to track(:signup_successful, { property: namespace.id.to_s })
.on_next_instance
.with_context(actor: user)
subject
end
context 'learn gitlab project' do context 'learn gitlab project' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
...@@ -183,7 +176,7 @@ RSpec.describe Registrations::ProjectsController do ...@@ -183,7 +176,7 @@ RSpec.describe Registrations::ProjectsController do
end end
context 'with signup onboarding not enabled' do context 'with signup onboarding not enabled' do
let(:signup_onboarding_enabled) { false } let(:dev_env_or_com) { false }
it { is_expected.to have_gitlab_http_status(:not_found) } it { is_expected.to have_gitlab_http_status(:not_found) }
end end
......
...@@ -10,7 +10,6 @@ RSpec.describe 'User is able to invite members to group during signup', :js, :ex ...@@ -10,7 +10,6 @@ RSpec.describe 'User is able to invite members to group during signup', :js, :ex
before do before do
allow(Gitlab).to receive(:dev_env_or_com?).and_return(true) allow(Gitlab).to receive(:dev_env_or_com?).and_return(true)
stub_experiments(registrations_group_invite: :invite_page)
sign_in(user) sign_in(user)
end end
......
...@@ -8,7 +8,6 @@ RSpec.describe 'User sees new onboarding flow', :js do ...@@ -8,7 +8,6 @@ RSpec.describe 'User sees new onboarding flow', :js do
before do before do
allow(Gitlab).to receive(:com?).and_return(true) allow(Gitlab).to receive(:com?).and_return(true)
stub_feature_flags(registrations_group_invite: false)
sign_in(user) sign_in(user)
visit users_sign_up_welcome_path visit users_sign_up_welcome_path
...@@ -20,13 +19,13 @@ RSpec.describe 'User sees new onboarding flow', :js do ...@@ -20,13 +19,13 @@ RSpec.describe 'User sees new onboarding flow', :js do
expect(page).to have_content('GitLab Ultimate trial (optional)') expect(page).to have_content('GitLab Ultimate trial (optional)')
end end
it 'shows the expected behavior with no trial chosen' do it 'shows the expected behavior with no trial chosen', :aggregate_failures do
fill_in 'group_name', with: 'test' fill_in 'group_name', with: 'test'
click_on 'Create group' click_on 'Create group'
expect(page).not_to have_content('Congratulations, your free trial is activated.') expect(page).not_to have_content('Congratulations, your free trial is activated.')
expect(page).to have_content('Create/import your first project') expect(page).to have_content('Invite your teammates')
end end
it 'shows the expected behavior with trial chosen' do it 'shows the expected behavior with trial chosen' do
...@@ -73,6 +72,6 @@ RSpec.describe 'User sees new onboarding flow', :js do ...@@ -73,6 +72,6 @@ RSpec.describe 'User sees new onboarding flow', :js do
click_on 'Create group' click_on 'Create group'
expect(page).to have_content('Congratulations, your free trial is activated.') expect(page).to have_content('Congratulations, your free trial is activated.')
expect(page).to have_content('Create/import your first project') expect(page).to have_content('Invite your teammates')
end end
end end
...@@ -5,7 +5,6 @@ require 'spec_helper' ...@@ -5,7 +5,6 @@ require 'spec_helper'
RSpec.describe 'User sees new onboarding flow', :js do RSpec.describe 'User sees new onboarding flow', :js do
before do before do
stub_const('Gitlab::QueryLimiting::Transaction::THRESHOLD', 200) stub_const('Gitlab::QueryLimiting::Transaction::THRESHOLD', 200)
stub_feature_flags(registration_group_invite: false)
allow(Gitlab).to receive(:com?).and_return(true) allow(Gitlab).to receive(:com?).and_return(true)
gitlab_sign_in(:user) gitlab_sign_in(:user)
visit users_sign_up_welcome_path visit users_sign_up_welcome_path
...@@ -29,6 +28,10 @@ RSpec.describe 'User sees new onboarding flow', :js do ...@@ -29,6 +28,10 @@ RSpec.describe 'User sees new onboarding flow', :js do
click_on 'Create group' click_on 'Create group'
expect(page).to have_content('Invite your teammates')
click_on 'Skip this for now'
expect(page).to have_content('Create/import your first project') expect(page).to have_content('Create/import your first project')
expect(page).to have_content('Your profile Your GitLab group Your first project') expect(page).to have_content('Your profile Your GitLab group Your first project')
expect(page).to have_css('li.current', text: 'Your first project') expect(page).to have_css('li.current', text: 'Your first project')
......
...@@ -7,12 +7,15 @@ RSpec.describe 'view group invites' do ...@@ -7,12 +7,15 @@ RSpec.describe 'view group invites' do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:not_authorized_group) { create(:group) } let_it_be(:not_authorized_group) { create(:group) }
let(:dev_env_or_com) { true }
before_all do before_all do
group.add_owner(user) group.add_owner(user)
end end
before do before do
login_as(user) login_as(user)
allow(::Gitlab).to receive(:dev_env_or_com?).and_return(dev_env_or_com)
end end
describe 'GET /users/sign_up/group_invites/new' do describe 'GET /users/sign_up/group_invites/new' do
...@@ -28,6 +31,16 @@ RSpec.describe 'view group invites' do ...@@ -28,6 +31,16 @@ RSpec.describe 'view group invites' do
end end
end end
context 'when not on .com' do
let(:dev_env_or_com) { false }
it 'returns not_found' do
get_request
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'when user is not authorized to invite for the group' do context 'when user is not authorized to invite for the group' do
let(:group_params) { { group_id: not_authorized_group.id } } let(:group_params) { { group_id: not_authorized_group.id } }
...@@ -59,12 +72,6 @@ RSpec.describe 'view group invites' do ...@@ -59,12 +72,6 @@ RSpec.describe 'view group invites' do
expect(group.members.invite).to be_empty expect(group.members.invite).to be_empty
end end
it 'does not track experiment', :experiment do
expect(experiment(:registrations_group_invite)).not_to track(:invites_sent)
post_request
end
end end
context 'with valid emails in the params' do context 'with valid emails in the params' do
...@@ -85,15 +92,6 @@ RSpec.describe 'view group invites' do ...@@ -85,15 +92,6 @@ RSpec.describe 'view group invites' do
user: user user: user
) )
end end
it 'tracks experiment as expected', :experiment do
expect(experiment(:registrations_group_invite))
.to track(:invites_sent, { property: group.id.to_s, value: valid_emails.size })
.on_next_instance
.with_context(actor: user)
post_request
end
end end
end end
...@@ -109,6 +107,16 @@ RSpec.describe 'view group invites' do ...@@ -109,6 +107,16 @@ RSpec.describe 'view group invites' do
end end
end end
context 'when not on .com' do
let(:dev_env_or_com) { false }
it 'returns not_found' do
post_request
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'when user is not authorized to invite for the group' do context 'when user is not authorized to invite for the group' do
let(:group_params) { { group_id: not_authorized_group.id } } let(:group_params) { { group_id: not_authorized_group.id } }
......
...@@ -35,9 +35,8 @@ RSpec.describe 'registrations/groups/new' do ...@@ -35,9 +35,8 @@ RSpec.describe 'registrations/groups/new' do
context 'in trial onboarding' do context 'in trial onboarding' do
let_it_be(:trial_onboarding_flow) { true } let_it_be(:trial_onboarding_flow) { true }
it 'hides trial form and shows invite members' do it 'hides trial form' do
is_expected.not_to have_content('Company name') is_expected.not_to have_content('Company name')
is_expected.to have_selector('.js-invite-members')
end end
it 'hides the progress bar' do it 'hides the progress bar' 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