diff --git a/ee/app/helpers/trials_helper.rb b/ee/app/helpers/trials_helper.rb index fdce0c67022232ad364a34f141fe6dd41e0a96eb..26375705f85a1d03770f12bb29822fdd79b50c8c 100644 --- a/ee/app/helpers/trials_helper.rb +++ b/ee/app/helpers/trials_helper.rb @@ -51,7 +51,7 @@ def duo_pro_trial_namespace_selector_data(namespace_create_errors) namespace_selector_data(namespace_create_errors).merge( any_trial_eligible_namespaces: namespaces.any?.to_s, - items: namespace_options_for_listbox(namespaces).to_json + items: current_namespaces_for_selector(namespaces).to_json ) end @@ -76,7 +76,7 @@ def show_tier_badge_for_new_trial?(namespace, user) end def namespace_options_for_listbox(namespaces) - group_options = namespaces.map { |n| { text: n.name, value: n.id.to_s } } + group_options = current_namespaces_for_selector(namespaces) options = [ { text: _('New'), @@ -96,6 +96,10 @@ def namespace_options_for_listbox(namespaces) private + def current_namespaces_for_selector(namespaces) + namespaces.map { |n| { text: n.name, value: n.id.to_s } } + end + def passed_through_params params.slice( :trial, diff --git a/ee/app/views/subscriptions/trials/duo_pro/_select_namespace_form.html.haml b/ee/app/views/subscriptions/trials/duo_pro/_select_namespace_form.html.haml index 761377a29bdf8653c97c8a47dfe670dff1e3c082..ba3c93f15b9217f348c39da7a822b6d985d7718e 100644 --- a/ee/app/views/subscriptions/trials/duo_pro/_select_namespace_form.html.haml +++ b/ee/app/views/subscriptions/trials/duo_pro/_select_namespace_form.html.haml @@ -11,10 +11,7 @@ = sprite_icon('tanuki-ai', size: 32, css_class: 'gl-pb-3') %h2.gl-pb-5.gl-my-0 - - if duo_pro_trial_eligible_namespaces.any? - = s_('DuoProTrial|Apply your GitLab Duo Pro trial to a new or existing group') - - else - = s_('DuoProTrial|Create a group to start your GitLab Duo Pro trial') + = s_('DuoProTrial|Apply your GitLab Duo Pro trial to an existing group') = yield :before_form diff --git a/ee/spec/helpers/trials_helper_spec.rb b/ee/spec/helpers/trials_helper_spec.rb index 2a276c1ff6e218c1a515379529d4a8dd22ccecf7..47227e3f4527de13203a6f25b0c668ff6444b158 100644 --- a/ee/spec/helpers/trials_helper_spec.rb +++ b/ee/spec/helpers/trials_helper_spec.rb @@ -330,19 +330,24 @@ ] end + let(:parsed_selector_data) { Gitlab::Json.parse(selector_data[:items]) } + before do allow(helper).to receive(:current_user).and_return(user) all_groups.map { |group| group.add_owner(user) } end describe '#trial_namespace_selector_data' do - subject { helper.trial_namespace_selector_data(nil) } + subject(:selector_data) { helper.trial_namespace_selector_data(nil) } it 'returns free group' do group_options = [{ 'text' => free.name, 'value' => free.id.to_s }] is_expected.to include(any_trial_eligible_namespaces: 'true') - expect(Gitlab::Json.parse(subject[:items])[1]['options']).to eq(group_options) + new_group_option = parsed_selector_data[0]['options'] + group_select_options = parsed_selector_data[1]['options'] + expect(new_group_option).to eq([{ 'text' => _('Create group'), 'value' => '0' }]) + expect(group_select_options).to eq(group_options) end end @@ -359,15 +364,15 @@ create(:gitlab_subscription_add_on, :gitlab_duo_pro) end - subject { helper.duo_pro_trial_namespace_selector_data(nil) } + subject(:selector_data) { helper.duo_pro_trial_namespace_selector_data(nil) } - it 'returns all groups' do + it 'returns all groups without create group option' do group_options = all_groups.map do |group| { 'text' => group.name, 'value' => group.id.to_s } end is_expected.to include(any_trial_eligible_namespaces: 'true') - expect(Gitlab::Json.parse(subject[:items])[1]['options']).to eq(group_options) + expect(parsed_selector_data).to eq(group_options) end end end diff --git a/ee/spec/requests/subscriptions/trials/duo_pro_controller_spec.rb b/ee/spec/requests/subscriptions/trials/duo_pro_controller_spec.rb index a83b260aa8c1b8ffad05a40b786f9e07505b36b7..cf2b85e8252c63252149dab63e10f08d879d5cfb 100644 --- a/ee/spec/requests/subscriptions/trials/duo_pro_controller_spec.rb +++ b/ee/spec/requests/subscriptions/trials/duo_pro_controller_spec.rb @@ -273,7 +273,7 @@ def expect_create_failure(reason, payload = {}) match do |response| expect(response).to have_gitlab_http_status(:ok) - expect(response.body).to include(s_('DuoProTrial|Apply your GitLab Duo Pro trial to a new or existing group')) + expect(response.body).to include(s_('DuoProTrial|Apply your GitLab Duo Pro trial to an existing group')) end end diff --git a/ee/spec/views/subscriptions/trials/duo_pro/_select_namespace_form.html.haml_spec.rb b/ee/spec/views/subscriptions/trials/duo_pro/_select_namespace_form.html.haml_spec.rb index e74c205a5cda3911adbb69466aa60b06276eeec8..1b698c5bc4a2c98806cd8269b086cd894e6ec700 100644 --- a/ee/spec/views/subscriptions/trials/duo_pro/_select_namespace_form.html.haml_spec.rb +++ b/ee/spec/views/subscriptions/trials/duo_pro/_select_namespace_form.html.haml_spec.rb @@ -3,34 +3,22 @@ require 'spec_helper' RSpec.describe 'subscriptions/trials/duo_pro/_select_namespace_form.html.haml', feature_category: :purchase do - let_it_be(:user) { build_stubbed(:user) } + let(:user) { build_stubbed(:user) } + let(:group) { build_stubbed(:group) } before do allow(view).to receive(:current_user) { user } + allow(view).to receive(:duo_pro_trial_eligible_namespaces).and_return([group]) end it 'renders select namespace form' do render 'subscriptions/trials/duo_pro/select_namespace_form' - expect(rendered).to have_content(s_('DuoProTrial|Create a group to start your GitLab Duo Pro trial')) + expect(rendered).to have_content(s_('DuoProTrial|Apply your GitLab Duo Pro trial to an existing group')) expect(rendered).to have_content(_('Who will be using GitLab?')) expect(rendered).to have_content(_('My company or team')) expect(rendered).to have_content(_('Just me')) expect(rendered).to render_template('subscriptions/trials/duo_pro/_advantages_list') end - - context 'when there is trial eligible namespace' do - let_it_be(:group) { build_stubbed(:group) } - - before do - allow(view).to receive(:duo_pro_trial_eligible_namespaces).and_return([group]) - end - - it 'renders correct title' do - render 'subscriptions/trials/duo_pro/select_namespace_form' - - expect(rendered).to have_content(s_('DuoProTrial|Apply your GitLab Duo Pro trial to a new or existing group')) - end - end end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 3063ec2a52d5935d178c1e3d7ed1090f06745957..c80738d283e803b53dcfc9a0c8f8298fdb8e384b 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -18732,7 +18732,7 @@ msgstr "" msgid "DuoProTrial|Activate my trial" msgstr "" -msgid "DuoProTrial|Apply your GitLab Duo Pro trial to a new or existing group" +msgid "DuoProTrial|Apply your GitLab Duo Pro trial to an existing group" msgstr "" msgid "DuoProTrial|Chat" @@ -18747,9 +18747,6 @@ msgstr "" msgid "DuoProTrial|Code refactorization" msgstr "" -msgid "DuoProTrial|Create a group to start your GitLab Duo Pro trial" -msgstr "" - msgid "DuoProTrial|GitLab Duo Pro is designed to make teams more efficient throughout the software development lifecycle with:" msgstr ""