summaryrefslogtreecommitdiff
path: root/spec/policies
diff options
context:
space:
mode:
authorMichael Kozono <mkozono@gmail.com>2017-09-01 18:00:46 -0700
committerMichael Kozono <mkozono@gmail.com>2017-09-06 12:07:20 -0700
commit6c57734677746aa0e6695aa75990a85a7f95b50d (patch)
tree792a4a0a0a8856ca4702c4464862b53d4bd9461b /spec/policies
parent1cc7f4a45d9e9fdf1943eb92d3cd2071ba497337 (diff)
downloadgitlab-ce-6c57734677746aa0e6695aa75990a85a7f95b50d.tar.gz
Enforce share_with_group_lock rules
…in Groups::UpdateService instead of only in the browser.
Diffstat (limited to 'spec/policies')
-rw-r--r--spec/policies/group_policy_spec.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/policies/group_policy_spec.rb b/spec/policies/group_policy_spec.rb
index 7f832bfa563..9fa63982790 100644
--- a/spec/policies/group_policy_spec.rb
+++ b/spec/policies/group_policy_spec.rb
@@ -242,4 +242,52 @@ describe GroupPolicy do
end
end
end
+
+ describe 'change_share_with_group_lock' do
+ context 'when the group has a parent' do
+ let(:group) { create(:group, parent: parent) }
+
+ context 'when the parent share_with_group_lock is enabled' do
+ let(:parent) { create(:group, share_with_group_lock: true) }
+ let(:current_user) { owner }
+
+ context 'when current_user owns the parent' do
+ before do
+ parent.add_owner(owner)
+ end
+
+ it { expect_allowed(:change_share_with_group_lock) }
+ end
+
+ context 'when current_user owns the group but not the parent' do
+ it { expect_disallowed(:change_share_with_group_lock) }
+ end
+ end
+
+ context 'when the parent share_with_group_lock is disabled' do
+ let(:parent) { create(:group) }
+ let(:current_user) { owner }
+
+ context 'when current_user owns the parent' do
+ before do
+ parent.add_owner(owner)
+ end
+
+ it { expect_allowed(:change_share_with_group_lock) }
+ end
+
+ context 'when current_user owns the group but not the parent' do
+ it { expect_allowed(:change_share_with_group_lock) }
+ end
+ end
+ end
+
+ context 'when the group does not have a parent' do
+ context 'when current_user owns the group' do
+ let(:current_user) { owner }
+
+ it { expect_allowed(:change_share_with_group_lock) }
+ end
+ end
+ end
end