diff --git a/.rubocop_todo/layout/first_hash_element_indentation.yml b/.rubocop_todo/layout/first_hash_element_indentation.yml index bd8bee3b69fb12e19c375c33f05f989eba0bad70..dc2f8610a51aad08053d894863f9010054c93a38 100644 --- a/.rubocop_todo/layout/first_hash_element_indentation.yml +++ b/.rubocop_todo/layout/first_hash_element_indentation.yml @@ -50,7 +50,6 @@ Layout/FirstHashElementIndentation: - 'ee/app/services/elastic/cluster_reindexing_service.rb' - 'ee/app/services/gitlab_subscriptions/plan_upgrade_service.rb' - 'ee/app/services/iterations/create_service.rb' - - 'ee/app/services/registrations/base_namespace_create_service.rb' - 'ee/app/services/resource_events/change_iteration_service.rb' - 'ee/app/services/security/token_revocation_service.rb' - 'ee/app/services/timebox_report_service.rb' diff --git a/ee/app/services/registrations/base_namespace_create_service.rb b/ee/app/services/registrations/base_namespace_create_service.rb index 3b2421ca1df1344802e01979d8d28e9ad0193d70..9a3907d7439505b7ffbbc1e9f1394d631784eba2 100644 --- a/ee/app/services/registrations/base_namespace_create_service.rb +++ b/ee/app/services/registrations/base_namespace_create_service.rb @@ -37,11 +37,8 @@ def in_trial_onboarding_flow? end def apply_trial - trial_user_information = glm_params.merge({ - namespace_id: group.id, - gitlab_com_trial: true, - sync_to_gl: true - }) + trial_user_information = glm_params.merge(namespace_id: group.id, gitlab_com_trial: true, sync_to_gl: true) + trial_user_information[:namespace] = group.slice(:id, :name, :path, :kind, :trial_ends_on) GitlabSubscriptions::Trials::ApplyTrialWorker.perform_async(user.id, trial_user_information.to_h) end diff --git a/ee/spec/services/registrations/import_namespace_create_service_spec.rb b/ee/spec/services/registrations/import_namespace_create_service_spec.rb index d0f3b95be28ef072c5c58ce9dd7e7cb7361b26cf..a178f58610d9b7dbb618e10b6a8532ce95272b5e 100644 --- a/ee/spec/services/registrations/import_namespace_create_service_spec.rb +++ b/ee/spec/services/registrations/import_namespace_create_service_spec.rb @@ -116,7 +116,8 @@ glm_content: 'content', namespace_id: group.id, gitlab_com_trial: true, - sync_to_gl: true + sync_to_gl: true, + namespace: group.slice(:id, :name, :path, :kind, :trial_ends_on) } ) end diff --git a/ee/spec/services/registrations/standard_namespace_create_service_spec.rb b/ee/spec/services/registrations/standard_namespace_create_service_spec.rb index d06b28442dbc2c69538147cb546120c221d3a69a..db7341fd23ebc1e44dfbd443b2bfc3735ad26d79 100644 --- a/ee/spec/services/registrations/standard_namespace_create_service_spec.rb +++ b/ee/spec/services/registrations/standard_namespace_create_service_spec.rb @@ -197,7 +197,8 @@ glm_content: 'content', namespace_id: group.id, gitlab_com_trial: true, - sync_to_gl: true + sync_to_gl: true, + namespace: group.slice(:id, :name, :path, :kind, :trial_ends_on) } ) end diff --git a/ee/spec/support/helpers/saas_registration_helpers.rb b/ee/spec/support/helpers/saas_registration_helpers.rb index a458d6a8322fc78ff6c076e0b95b9c1f4438d058..0ea103a370195d3be0143613856def8992dfa497 100644 --- a/ee/spec/support/helpers/saas_registration_helpers.rb +++ b/ee/spec/support/helpers/saas_registration_helpers.rb @@ -123,7 +123,14 @@ def expect_to_apply_trial trial_user_information = { namespace_id: anything, gitlab_com_trial: true, - sync_to_gl: true + sync_to_gl: true, + namespace: { + id: anything, + name: 'Test Group', + path: 'test-group', + kind: 'group', + trial_ends_on: nil + } }.merge(glm_params) expect(GitlabSubscriptions::Trials::ApplyTrialWorker) @@ -176,7 +183,14 @@ def fills_in_group_and_project_creation_form_with_trial trial_user_information = { namespace_id: anything, gitlab_com_trial: true, - sync_to_gl: true + sync_to_gl: true, + namespace: { + id: anything, + name: 'Test Group', + path: 'test-group', + kind: 'group', + trial_ends_on: nil + } }.merge(glm_params) expect(GitlabSubscriptions::Trials::ApplyTrialWorker) diff --git a/ee/spec/workers/gitlab_subscriptions/trials/apply_trial_worker_spec.rb b/ee/spec/workers/gitlab_subscriptions/trials/apply_trial_worker_spec.rb index f46df1b962f56d13bb579f9ed162620e87d4b880..02965fb9ab0879776259bd931d00ca390478c374 100644 --- a/ee/spec/workers/gitlab_subscriptions/trials/apply_trial_worker_spec.rb +++ b/ee/spec/workers/gitlab_subscriptions/trials/apply_trial_worker_spec.rb @@ -11,13 +11,19 @@ context 'when valid to generate a trial' do let_it_be(:namespace) { create(:namespace) } - let(:trial_user_information) { { 'namespace_id' => namespace.id } } + let(:trial_user_information) do + { + 'namespace_id' => namespace.id, + 'namespace' => namespace.slice(:id, :name, :path, :kind, :trial_ends_on).stringify_keys + } + end context 'when trial is successfully applied' do let(:service) { instance_double(GitlabSubscriptions::Trials::ApplyTrialService) } before do - allow(GitlabSubscriptions::Trials::ApplyTrialService).to receive(:new).and_return(service) + trial_params = { uid: user.id, trial_user_information: trial_user_information.deep_symbolize_keys } + allow(GitlabSubscriptions::Trials::ApplyTrialService).to receive(:new).with(trial_params).and_return(service) allow(service).to receive(:execute).and_return(ServiceResponse.success) end