Commit 7dc8e0b5 authored by Simon Knox's avatar Simon Knox

Merge branch 'vij-disable-cap-external' into 'master'

Disable user cap input if shared externally

See merge request gitlab-org/gitlab!76130
parents 456be7e9 a746c36c
- 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.")
......@@ -432,32 +432,58 @@ RSpec.describe 'Edit group settings' do
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
......
......@@ -38633,6 +38633,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 ""
......
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