summaryrefslogtreecommitdiff
path: root/spec/policies
diff options
context:
space:
mode:
Diffstat (limited to 'spec/policies')
-rw-r--r--spec/policies/project_snippet_policy_spec.rb48
1 files changed, 35 insertions, 13 deletions
diff --git a/spec/policies/project_snippet_policy_spec.rb b/spec/policies/project_snippet_policy_spec.rb
index b55d565a57c..c5077e119bc 100644
--- a/spec/policies/project_snippet_policy_spec.rb
+++ b/spec/policies/project_snippet_policy_spec.rb
@@ -20,28 +20,39 @@ describe ProjectSnippetPolicy do
subject { described_class.new(current_user, snippet) }
shared_examples 'regular user access rights' do
- context 'project team member (non guest)' do
- before do
- project.add_developer(current_user)
- end
+ context 'not snippet author' do
+ context 'project team member (non guest)' do
+ before do
+ project.add_developer(current_user)
+ end
- it do
- expect_allowed(:read_snippet, :create_note)
- expect_disallowed(*author_permissions)
+ it do
+ expect_allowed(:read_snippet, :create_note)
+ expect_disallowed(*author_permissions)
+ end
end
- end
- context 'project team member (guest)' do
- before do
- project.add_guest(current_user)
- end
+ context 'project team member (guest)' do
+ before do
+ project.add_guest(current_user)
+ end
- context 'not snippet author' do
it do
expect_allowed(:read_snippet, :create_note)
expect_disallowed(:admin_snippet)
end
end
+
+ context 'project team member (maintainer)' do
+ before do
+ project.add_maintainer(current_user)
+ end
+
+ it do
+ expect_allowed(:read_snippet, :create_note)
+ expect_allowed(*author_permissions)
+ end
+ end
end
context 'snippet author' do
@@ -69,6 +80,17 @@ describe ProjectSnippetPolicy do
end
end
+ context 'project team member (maintainer)' do
+ before do
+ project.add_maintainer(current_user)
+ end
+
+ it do
+ expect_allowed(:read_snippet, :create_note)
+ expect_allowed(*author_permissions)
+ end
+ end
+
context 'not a project member' do
it do
expect_allowed(:read_snippet, :create_note)