diff --git a/ee/app/views/groups/_user_caps_setting.html.haml b/ee/app/views/groups/_user_caps_setting.html.haml index bca74c98e5838cced98f743ca3204fe2c260d07b..51156b0fb51a687bca4f4635685946361e300128 100644 --- a/ee/app/views/groups/_user_caps_setting.html.haml +++ b/ee/app/views/groups/_user_caps_setting.html.haml @@ -1,7 +1,10 @@ -- return unless group.user_cap_available? +- return unless group.root? && group.user_cap_available? .form-group = f.label :new_user_signups_cap, _('User cap'), class: 'gl-font-weight-bold' .form-text.text-muted= saas_user_caps_help_text(group) - = f.number_field :new_user_signups_cap, min: 1, class: 'form-control form-control-sm gl-form-input gl-w-full gl-mt-3' + = f.number_field :new_user_signups_cap, min: 1, class: 'form-control form-control-sm gl-form-input gl-w-full gl-mt-3', disabled: group.shared_externally? + - if group.shared_externally? + .form-text.text-muted= _("User cap cannot be enabled. The group or one of its subgroups or projects is shared externally.") + diff --git a/ee/spec/features/groups/group_settings_spec.rb b/ee/spec/features/groups/group_settings_spec.rb index 599fc83daafc52348bd959e0ecf89acedf8582b7..e7bd850e70b3dd9c84738c41f86adf920f4f5dfe 100644 --- a/ee/spec/features/groups/group_settings_spec.rb +++ b/ee/spec/features/groups/group_settings_spec.rb @@ -432,32 +432,58 @@ def update_email_domains(new_domain) context 'when user cap feature is available', :js do let(:user_caps_selector) { '[name="group[new_user_signups_cap]"]' } - before do - visit edit_group_path(group) - end + context 'when group is not the root group' do + let(:subgroup) { create(:group, parent: group) } - it 'is visible' do - expect(page).to have_content('User cap') + before do + visit edit_group_path(subgroup) + end + + it 'is not visible' do + expect(page).not_to have_content('User cap') + end end - it 'will save positive numbers' do - find(user_caps_selector).set(5) + context 'when the group is the root group' do + before do + visit edit_group_path(group) + end - click_button 'Save changes' - wait_for_requests + it 'is visible' do + expect(page).to have_content('User cap') + end - expect(page).to have_content("Group 'Foo bar' was successfully updated.") - end + it 'will save positive numbers' do + find(user_caps_selector).set(5) - it 'will not allow negative number' do - find(user_caps_selector).set(-5) + click_button 'Save changes' + wait_for_requests + + expect(page).to have_content("Group 'Foo bar' was successfully updated.") + end + + it 'will not allow negative number' do + find(user_caps_selector).set(-5) + + click_button 'Save changes' + expect(page).to have_content('This field is required.') - click_button 'Save changes' - expect(page).to have_content('This field is required.') + wait_for_requests + + expect(page).not_to have_content("Group 'Foo bar' was successfully updated.") + end - wait_for_requests + context 'when the group cannot set a user cap' do + before do + create(:group_group_link, shared_group: group) - expect(page).not_to have_content("Group 'Foo bar' was successfully updated.") + visit edit_group_path(group) + end + + it 'will be a disabled input' do + expect(find(user_caps_selector)).to be_disabled + end + end end end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 827ff8642528d87566cd4ed752eb7c9acc322e8f..40313e0cb593c8cf71da412fe777c2575f53d4ab 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -38627,6 +38627,9 @@ msgstr "" msgid "User cap" msgstr "" +msgid "User cap cannot be enabled. The group or one of its subgroups or projects is shared externally." +msgstr "" + msgid "User created at" msgstr ""