Commit 6a9c73e7 authored by Doug Stull's avatar Doug Stull

Merge branch 'jswain_assign_setup_for_company_to_namespace' into 'master'

Assign setup_for_company to namespace in reg flow

See merge request gitlab-org/gitlab!74454
parents 88583e09 dbf58a96
...@@ -20,7 +20,14 @@ module Registrations::CreateGroup ...@@ -20,7 +20,14 @@ module Registrations::CreateGroup
end end
def group_params def group_params
params.require(:group).permit(:name, :path, :visibility_level) params.require(:group).permit(
:name,
:path,
:visibility_level
).merge(
create_event: true,
setup_for_company: current_user.setup_for_company
)
end end
end end
end end
...@@ -17,7 +17,7 @@ module Registrations ...@@ -17,7 +17,7 @@ module Registrations
end end
def create def create
@group = Groups::CreateService.new(current_user, group_params.merge(create_event: true)).execute @group = Groups::CreateService.new(current_user, group_params).execute
if @group.persisted? if @group.persisted?
experiment(:combined_registration, user: current_user).track(:create_group, namespace: @group) experiment(:combined_registration, user: current_user).track(:create_group, namespace: @group)
......
...@@ -90,7 +90,7 @@ module Registrations ...@@ -90,7 +90,7 @@ module Registrations
modifed_group_params = modifed_group_params.compact_blank.with_defaults(path: Namespace.clean_path(group_name)) modifed_group_params = modifed_group_params.compact_blank.with_defaults(path: Namespace.clean_path(group_name))
end end
modifed_group_params.merge(create_event: true) modifed_group_params
end end
end end
end end
...@@ -14,7 +14,8 @@ RSpec.describe Registrations::GroupsController do ...@@ -14,7 +14,8 @@ RSpec.describe Registrations::GroupsController do
let_it_be(:trial_onboarding_flow_params) { {} } let_it_be(:trial_onboarding_flow_params) { {} }
let(:dev_env_or_com) { true } let(:dev_env_or_com) { true }
let(:group_params) { { name: 'Group name', path: 'group-path', visibility_level: Gitlab::VisibilityLevel::PRIVATE.to_s } } let(:group_params) { { name: 'Group name', path: 'group-path', visibility_level: Gitlab::VisibilityLevel::PRIVATE.to_s, create_event: true, setup_for_company: setup_for_company } }
let(:setup_for_company) { nil }
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)
end end
...@@ -40,12 +41,23 @@ RSpec.describe Registrations::GroupsController do ...@@ -40,12 +41,23 @@ RSpec.describe Registrations::GroupsController do
expect { post_create }.to change { Group.count }.by(1) expect { post_create }.to change { Group.count }.by(1)
end end
it 'passes create_event to Groups::CreateService' do it 'passes group_params to Groups::CreateService' do
expect(Groups::CreateService).to receive(:new).with(user, ActionController::Parameters.new(group_params.merge(create_event: true)).permit!).and_call_original expect(Groups::CreateService).to receive(:new).with(user, ActionController::Parameters.new(group_params).permit!).and_call_original
post_create post_create
end end
context 'when the user is `setup_for_company: true`' do
let(:user) { create(:user, setup_for_company: setup_for_company) }
let(:setup_for_company) { true }
it 'passes `setup_for_company: true` to the Groups::CreateService' do
expect(Groups::CreateService).to receive(:new).with(user, ActionController::Parameters.new(group_params).permit!).and_call_original
post_create
end
end
context 'when in trial onboarding - apply_trial_for_trial_onboarding_flow' do context 'when in trial onboarding - apply_trial_for_trial_onboarding_flow' do
let_it_be(:group) { create(:group) } 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_flow_params) { { trial_onboarding_flow: true, glm_source: 'about.gitlab.com', glm_content: 'content' } }
......
...@@ -36,9 +36,10 @@ RSpec.describe Registrations::GroupsProjectsController, :experiment do ...@@ -36,9 +36,10 @@ RSpec.describe Registrations::GroupsProjectsController, :experiment do
let(:params) { { group: group_params, project: project_params }.merge(extra_params) } let(:params) { { group: group_params, project: project_params }.merge(extra_params) }
let(:extra_params) { {} } let(:extra_params) { {} }
let(:group_params) { { name: 'Group name', path: 'group-path', visibility_level: Gitlab::VisibilityLevel::PRIVATE.to_s } } let(:group_params) { { name: 'Group name', path: 'group-path', visibility_level: Gitlab::VisibilityLevel::PRIVATE.to_s, setup_for_company: setup_for_company } }
let(:project_params) { { name: 'New project', path: 'project-path', visibility_level: Gitlab::VisibilityLevel::PRIVATE } } let(:project_params) { { name: 'New project', path: 'project-path', visibility_level: Gitlab::VisibilityLevel::PRIVATE } }
let(:dev_env_or_com) { true } let(:dev_env_or_com) { true }
let(:setup_for_company) { nil }
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) }
...@@ -189,7 +190,7 @@ RSpec.describe Registrations::GroupsProjectsController, :experiment do ...@@ -189,7 +190,7 @@ RSpec.describe Registrations::GroupsProjectsController, :experiment do
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
let_it_be(:namespace) { create(:group) } let_it_be(:namespace) { create(:group) }
let(:group_params) { { name: 'Group name', path: 'group-path', visibility_level: "#{Gitlab::VisibilityLevel::PRIVATE}" } } let(:group_params) { { name: 'Group name', path: 'group-path', visibility_level: "#{Gitlab::VisibilityLevel::PRIVATE}", setup_for_company: setup_for_company } }
let(:extra_params) { { group: group_params } } let(:extra_params) { { group: group_params } }
let(:params) { { name: 'New project', path: 'project-path', visibility_level: Gitlab::VisibilityLevel::PRIVATE } } let(:params) { { name: 'New project', path: 'project-path', visibility_level: Gitlab::VisibilityLevel::PRIVATE } }
let(:create_service) { double(:create_service) } let(:create_service) { double(:create_service) }
...@@ -209,10 +210,12 @@ RSpec.describe Registrations::GroupsProjectsController, :experiment do ...@@ -209,10 +210,12 @@ RSpec.describe Registrations::GroupsProjectsController, :experiment do
end end
context 'when the user is setup_for_company: true it redirects to the new_trial_path' do context 'when the user is setup_for_company: true it redirects to the new_trial_path' do
let(:setup_for_company) { true }
it_behaves_like "Registrations::ProjectsController POST #create" 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_it_be(:first_project) { create(:project) }
let(:user) { create(:user, setup_for_company: setup_for_company) }
let(:success_path) { new_trial_path } let(:success_path) { new_trial_path }
let(:stored_location_for) { continuous_onboarding_getting_started_users_sign_up_welcome_path(project_id: first_project.id) } let(:stored_location_for) { continuous_onboarding_getting_started_users_sign_up_welcome_path(project_id: first_project.id) }
...@@ -225,7 +228,7 @@ RSpec.describe Registrations::GroupsProjectsController, :experiment do ...@@ -225,7 +228,7 @@ RSpec.describe Registrations::GroupsProjectsController, :experiment do
subject(:post_import) { post :import, params: params } subject(:post_import) { post :import, params: params }
let(:params) { { group: group_params, import_url: new_import_github_path } } let(:params) { { group: group_params, import_url: new_import_github_path } }
let(:group_params) { { name: 'Group name', path: 'group-path', visibility_level: Gitlab::VisibilityLevel::PRIVATE.to_s } } let(:group_params) { { name: 'Group name', path: 'group-path', visibility_level: Gitlab::VisibilityLevel::PRIVATE.to_s, setup_for_company: nil } }
let(:dev_env_or_com) { true } let(:dev_env_or_com) { true }
context 'with an unauthenticated user' do context 'with an unauthenticated user' do
......
...@@ -24,6 +24,16 @@ RSpec.describe Groups::CreateService, '#execute' do ...@@ -24,6 +24,16 @@ RSpec.describe Groups::CreateService, '#execute' do
end end
end end
context 'when `setup_for_company:true` is passed' do
let(:params) { group_params.merge(setup_for_company: true) }
let(:service) { described_class.new(user, params) }
let(:created_group) { service.execute }
it 'creates group with the specified setup_for_company' do
expect(created_group.setup_for_company).to eq(true)
end
end
context 'creating a group with `default_branch_protection` attribute' do context 'creating a group with `default_branch_protection` attribute' do
let(:params) { group_params.merge(default_branch_protection: Gitlab::Access::PROTECTION_NONE) } let(:params) { group_params.merge(default_branch_protection: Gitlab::Access::PROTECTION_NONE) }
let(:service) { described_class.new(user, params) } let(:service) { described_class.new(user, params) }
......
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