Skip to content
代码片段 群组 项目
未验证 提交 de15ee63 编辑于 作者: Doug Stull's avatar Doug Stull 提交者: GitLab
浏览文件

Merge branch '451776-restrict-group-creation' into 'master'

Remove create group option from duo pro trials

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/147843



Merged-by: default avatarDoug Stull <dstull@gitlab.com>
Approved-by: default avatarSerhii Yarynovskyi <syarynovskyi@gitlab.com>
Approved-by: default avatarJaviera Tapia <jtapia@gitlab.com>
Reviewed-by: default avatarDoug Stull <dstull@gitlab.com>
No related branches found
No related tags found
无相关合并请求
...@@ -51,7 +51,7 @@ def duo_pro_trial_namespace_selector_data(namespace_create_errors) ...@@ -51,7 +51,7 @@ def duo_pro_trial_namespace_selector_data(namespace_create_errors)
namespace_selector_data(namespace_create_errors).merge( namespace_selector_data(namespace_create_errors).merge(
any_trial_eligible_namespaces: namespaces.any?.to_s, 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 end
...@@ -76,7 +76,7 @@ def show_tier_badge_for_new_trial?(namespace, user) ...@@ -76,7 +76,7 @@ def show_tier_badge_for_new_trial?(namespace, user)
end end
def namespace_options_for_listbox(namespaces) 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 = [ options = [
{ {
text: _('New'), text: _('New'),
...@@ -96,6 +96,10 @@ def namespace_options_for_listbox(namespaces) ...@@ -96,6 +96,10 @@ def namespace_options_for_listbox(namespaces)
private private
def current_namespaces_for_selector(namespaces)
namespaces.map { |n| { text: n.name, value: n.id.to_s } }
end
def passed_through_params def passed_through_params
params.slice( params.slice(
:trial, :trial,
......
...@@ -11,10 +11,7 @@ ...@@ -11,10 +11,7 @@
= sprite_icon('tanuki-ai', size: 32, css_class: 'gl-pb-3') = sprite_icon('tanuki-ai', size: 32, css_class: 'gl-pb-3')
%h2.gl-pb-5.gl-my-0 %h2.gl-pb-5.gl-my-0
- if duo_pro_trial_eligible_namespaces.any? = s_('DuoProTrial|Apply your GitLab Duo Pro trial to an existing group')
= 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')
= yield :before_form = yield :before_form
......
...@@ -330,19 +330,24 @@ ...@@ -330,19 +330,24 @@
] ]
end end
let(:parsed_selector_data) { Gitlab::Json.parse(selector_data[:items]) }
before do before do
allow(helper).to receive(:current_user).and_return(user) allow(helper).to receive(:current_user).and_return(user)
all_groups.map { |group| group.add_owner(user) } all_groups.map { |group| group.add_owner(user) }
end end
describe '#trial_namespace_selector_data' do 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 it 'returns free group' do
group_options = [{ 'text' => free.name, 'value' => free.id.to_s }] group_options = [{ 'text' => free.name, 'value' => free.id.to_s }]
is_expected.to include(any_trial_eligible_namespaces: 'true') 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
end end
...@@ -359,15 +364,15 @@ ...@@ -359,15 +364,15 @@
create(:gitlab_subscription_add_on, :gitlab_duo_pro) create(:gitlab_subscription_add_on, :gitlab_duo_pro)
end 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| group_options = all_groups.map do |group|
{ 'text' => group.name, 'value' => group.id.to_s } { 'text' => group.name, 'value' => group.id.to_s }
end end
is_expected.to include(any_trial_eligible_namespaces: 'true') 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 end
end end
......
...@@ -273,7 +273,7 @@ def expect_create_failure(reason, payload = {}) ...@@ -273,7 +273,7 @@ def expect_create_failure(reason, payload = {})
match do |response| match do |response|
expect(response).to have_gitlab_http_status(:ok) 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
end end
......
...@@ -3,34 +3,22 @@ ...@@ -3,34 +3,22 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'subscriptions/trials/duo_pro/_select_namespace_form.html.haml', feature_category: :purchase do 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 before do
allow(view).to receive(:current_user) { user } allow(view).to receive(:current_user) { user }
allow(view).to receive(:duo_pro_trial_eligible_namespaces).and_return([group])
end end
it 'renders select namespace form' do it 'renders select namespace form' do
render 'subscriptions/trials/duo_pro/select_namespace_form' 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(_('Who will be using GitLab?'))
expect(rendered).to have_content(_('My company or team')) expect(rendered).to have_content(_('My company or team'))
expect(rendered).to have_content(_('Just me')) expect(rendered).to have_content(_('Just me'))
expect(rendered).to render_template('subscriptions/trials/duo_pro/_advantages_list') expect(rendered).to render_template('subscriptions/trials/duo_pro/_advantages_list')
end 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 end
...@@ -18732,7 +18732,7 @@ msgstr "" ...@@ -18732,7 +18732,7 @@ msgstr ""
msgid "DuoProTrial|Activate my trial" msgid "DuoProTrial|Activate my trial"
msgstr "" 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 "" msgstr ""
   
msgid "DuoProTrial|Chat" msgid "DuoProTrial|Chat"
...@@ -18747,9 +18747,6 @@ msgstr "" ...@@ -18747,9 +18747,6 @@ msgstr ""
msgid "DuoProTrial|Code refactorization" msgid "DuoProTrial|Code refactorization"
msgstr "" 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:" msgid "DuoProTrial|GitLab Duo Pro is designed to make teams more efficient throughout the software development lifecycle with:"
msgstr "" msgstr ""
   
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册