Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Kozono <mkozono@gmail.com>2017-09-05 20:38:24 +0300
committerMichael Kozono <mkozono@gmail.com>2017-09-06 22:07:20 +0300
commitc7e17abd269e31a59c41687459eea6382475ab95 (patch)
tree3c3f390db48c9ae1f75da0cd8d838eadea7c69b9 /spec/policies
parente0fb7766bcbf140d1cc8165b4fae90fa8df841e6 (diff)
Fix “Share lock” policy for deeply nested groups
Diffstat (limited to 'spec/policies')
-rw-r--r--spec/policies/group_policy_spec.rb42
1 files changed, 34 insertions, 8 deletions
diff --git a/spec/policies/group_policy_spec.rb b/spec/policies/group_policy_spec.rb
index dcc7b7d5b9c..fdf588f6455 100644
--- a/spec/policies/group_policy_spec.rb
+++ b/spec/policies/group_policy_spec.rb
@@ -248,19 +248,45 @@ describe GroupPolicy 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
+ context 'when the group has a grandparent' do
+ let(:grandparent) { create(:group, share_with_group_lock: true) }
+ let(:parent) { create(:group, share_with_group_lock: true, parent: grandparent) }
- it { expect_allowed(:change_share_with_group_lock) }
+ context 'and the grandparent share_with_group_lock is enabled' do
+ context 'when current_user owns the grandparent' do
+ before do
+ grandparent.add_owner(owner)
+ end
+
+ it { expect_allowed(:change_share_with_group_lock) }
+ end
+
+ context 'when current_user owns the parent but not the grandparent' do
+ before do
+ parent.add_owner(owner)
+ end
+
+ it { expect_disallowed(:change_share_with_group_lock) }
+ end
+ end
end
- context 'when current_user owns the group but not the parent' do
- it { expect_disallowed(:change_share_with_group_lock) }
+ context 'when the group does not have a grandparent' do
+ let(:parent) { create(:group, share_with_group_lock: true) }
+
+ 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
end