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,6 +432,19 @@ 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]"]' }
context 'when group is not the root group' do
let(:subgroup) { create(:group, parent: group) }
before do
visit edit_group_path(subgroup)
end
it 'is not visible' do
expect(page).not_to have_content('User cap')
end
end
context 'when the group is the root group' do
before do
visit edit_group_path(group)
end
......@@ -459,6 +472,19 @@ RSpec.describe 'Edit group settings' do
expect(page).not_to have_content("Group 'Foo bar' was successfully updated.")
end
context 'when the group cannot set a user cap' do
before do
create(:group_group_link, shared_group: group)
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
describe 'form submit button', :js do
......
......@@ -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