diff options
author | Michael Kozono <mkozono@gmail.com> | 2017-09-01 18:00:46 -0700 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2017-09-06 12:07:20 -0700 |
commit | 6c57734677746aa0e6695aa75990a85a7f95b50d (patch) | |
tree | 792a4a0a0a8856ca4702c4464862b53d4bd9461b /spec/services/groups | |
parent | 1cc7f4a45d9e9fdf1943eb92d3cd2071ba497337 (diff) | |
download | gitlab-ce-6c57734677746aa0e6695aa75990a85a7f95b50d.tar.gz |
Enforce share_with_group_lock rules
…in Groups::UpdateService instead of only in the browser.
Diffstat (limited to 'spec/services/groups')
-rw-r--r-- | spec/services/groups/update_service_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/services/groups/update_service_spec.rb b/spec/services/groups/update_service_spec.rb index 44f22a3b37b..aa8e058903b 100644 --- a/spec/services/groups/update_service_spec.rb +++ b/spec/services/groups/update_service_spec.rb @@ -100,4 +100,38 @@ describe Groups::UpdateService do end end end + + context 'for a subgroup' do + let(:subgroup) { create(:group, :private, parent: private_group) } + + context 'when the parent group share_with_group_lock is enabled' do + before do + private_group.update_column(:share_with_group_lock, true) + end + + context 'for the parent group owner' do + it 'allows disabling share_with_group_lock' do + private_group.add_owner(user) + + result = described_class.new(subgroup, user, share_with_group_lock: false).execute + + expect(result).to be_truthy + expect(subgroup.reload.share_with_group_lock).to be_falsey + end + end + + context 'for a subgroup owner (who does not own the parent)' do + it 'does not allow disabling share_with_group_lock' do + subgroup_owner = create(:user) + subgroup.add_owner(subgroup_owner) + + result = described_class.new(subgroup, subgroup_owner, share_with_group_lock: false).execute + + expect(result).to be_falsey + expect(subgroup.errors.full_messages.first).to match(/cannot be disabled when the parent group Share lock is enabled, except by the owner of the parent group/) + expect(subgroup.reload.share_with_group_lock).to be_truthy + end + end + end + end end |