summaryrefslogtreecommitdiff
path: root/spec/policies
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-23 12:08:38 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-23 12:08:38 +0000
commit5ad0cf26551baff8f08af8562a8d45e6ec14d71a (patch)
tree57f1a6bad31bcd11efacd3fdfb9cc92f88fb6a86 /spec/policies
parentf47c768fad17d4c876e96524f83f8306f071db66 (diff)
downloadgitlab-ce-5ad0cf26551baff8f08af8562a8d45e6ec14d71a.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/policies')
-rw-r--r--spec/policies/global_policy_spec.rb8
-rw-r--r--spec/policies/note_policy_spec.rb41
-rw-r--r--spec/policies/personal_snippet_policy_spec.rb28
-rw-r--r--spec/policies/project_policy_spec.rb8
-rw-r--r--spec/policies/project_snippet_policy_spec.rb46
5 files changed, 66 insertions, 65 deletions
diff --git a/spec/policies/global_policy_spec.rb b/spec/policies/global_policy_spec.rb
index f715ecae347..77727c6d13b 100644
--- a/spec/policies/global_policy_spec.rb
+++ b/spec/policies/global_policy_spec.rb
@@ -307,21 +307,21 @@ describe GlobalPolicy do
end
end
- describe 'create_personal_snippet' do
+ describe 'create_snippet' do
context 'when anonymous' do
let(:current_user) { nil }
- it { is_expected.not_to be_allowed(:create_personal_snippet) }
+ it { is_expected.not_to be_allowed(:create_snippet) }
end
context 'regular user' do
- it { is_expected.to be_allowed(:create_personal_snippet) }
+ it { is_expected.to be_allowed(:create_snippet) }
end
context 'when external' do
let(:current_user) { build(:user, :external) }
- it { is_expected.not_to be_allowed(:create_personal_snippet) }
+ it { is_expected.not_to be_allowed(:create_snippet) }
end
end
end
diff --git a/spec/policies/note_policy_spec.rb b/spec/policies/note_policy_spec.rb
index 5aee66275d4..2619bb2fe3c 100644
--- a/spec/policies/note_policy_spec.rb
+++ b/spec/policies/note_policy_spec.rb
@@ -54,6 +54,27 @@ describe NotePolicy do
end
end
+ context 'when the noteable is a personal snippet' do
+ let(:noteable) { create(:personal_snippet, :public) }
+ let(:note) { create(:note, noteable: noteable, author: user) }
+
+ it 'can edit note' do
+ expect(policy).to be_allowed(:admin_note)
+ expect(policy).to be_allowed(:resolve_note)
+ expect(policy).to be_allowed(:read_note)
+ end
+
+ context 'when it is private' do
+ let(:noteable) { create(:personal_snippet, :private) }
+
+ it 'can not edit nor read the note' do
+ expect(policy).to be_disallowed(:admin_note)
+ expect(policy).to be_disallowed(:resolve_note)
+ expect(policy).to be_disallowed(:read_note)
+ end
+ end
+ end
+
context 'when the project is public' do
context 'when the note author is not a project member' do
it 'can edit a note' do
@@ -79,26 +100,6 @@ describe NotePolicy do
end
end
- context 'when the noteable is a personal snippet' do
- let(:noteable) { create(:personal_snippet, :public) }
-
- it 'can edit note' do
- expect(policy).to be_allowed(:admin_note)
- expect(policy).to be_allowed(:resolve_note)
- expect(policy).to be_allowed(:read_note)
- end
-
- context 'when it is private' do
- let(:noteable) { create(:personal_snippet, :private) }
-
- it 'can not edit nor read the note' do
- expect(policy).to be_disallowed(:admin_note)
- expect(policy).to be_disallowed(:resolve_note)
- expect(policy).to be_disallowed(:read_note)
- end
- end
- end
-
context 'when a discussion is confidential' do
before do
issue.update_attribute(:confidential, true)
diff --git a/spec/policies/personal_snippet_policy_spec.rb b/spec/policies/personal_snippet_policy_spec.rb
index 0abdf7382be..a6b76620c29 100644
--- a/spec/policies/personal_snippet_policy_spec.rb
+++ b/spec/policies/personal_snippet_policy_spec.rb
@@ -10,8 +10,8 @@ describe PersonalSnippetPolicy do
let(:author_permissions) do
[
- :update_personal_snippet,
- :admin_personal_snippet
+ :update_snippet,
+ :admin_snippet
]
end
@@ -24,7 +24,7 @@ describe PersonalSnippetPolicy do
subject { permissions(admin_user) }
it do
- is_expected.to be_allowed(:read_personal_snippet)
+ is_expected.to be_allowed(:read_snippet)
is_expected.to be_allowed(:create_note)
is_expected.to be_allowed(:award_emoji)
is_expected.to be_allowed(*author_permissions)
@@ -39,7 +39,7 @@ describe PersonalSnippetPolicy do
subject { permissions(nil) }
it do
- is_expected.to be_allowed(:read_personal_snippet)
+ is_expected.to be_allowed(:read_snippet)
is_expected.to be_disallowed(:create_note)
is_expected.to be_disallowed(:award_emoji)
is_expected.to be_disallowed(*author_permissions)
@@ -50,7 +50,7 @@ describe PersonalSnippetPolicy do
subject { permissions(regular_user) }
it do
- is_expected.to be_allowed(:read_personal_snippet)
+ is_expected.to be_allowed(:read_snippet)
is_expected.to be_allowed(:create_note)
is_expected.to be_allowed(:award_emoji)
is_expected.to be_disallowed(*author_permissions)
@@ -61,7 +61,7 @@ describe PersonalSnippetPolicy do
subject { permissions(snippet.author) }
it do
- is_expected.to be_allowed(:read_personal_snippet)
+ is_expected.to be_allowed(:read_snippet)
is_expected.to be_allowed(:create_note)
is_expected.to be_allowed(:award_emoji)
is_expected.to be_allowed(*author_permissions)
@@ -78,7 +78,7 @@ describe PersonalSnippetPolicy do
subject { permissions(nil) }
it do
- is_expected.to be_disallowed(:read_personal_snippet)
+ is_expected.to be_disallowed(:read_snippet)
is_expected.to be_disallowed(:create_note)
is_expected.to be_disallowed(:award_emoji)
is_expected.to be_disallowed(*author_permissions)
@@ -89,7 +89,7 @@ describe PersonalSnippetPolicy do
subject { permissions(regular_user) }
it do
- is_expected.to be_allowed(:read_personal_snippet)
+ is_expected.to be_allowed(:read_snippet)
is_expected.to be_allowed(:create_note)
is_expected.to be_allowed(:award_emoji)
is_expected.to be_disallowed(*author_permissions)
@@ -100,7 +100,7 @@ describe PersonalSnippetPolicy do
subject { permissions(external_user) }
it do
- is_expected.to be_disallowed(:read_personal_snippet)
+ is_expected.to be_disallowed(:read_snippet)
is_expected.to be_disallowed(:create_note)
is_expected.to be_disallowed(:award_emoji)
is_expected.to be_disallowed(*author_permissions)
@@ -111,7 +111,7 @@ describe PersonalSnippetPolicy do
subject { permissions(snippet.author) }
it do
- is_expected.to be_allowed(:read_personal_snippet)
+ is_expected.to be_allowed(:read_snippet)
is_expected.to be_allowed(:create_note)
is_expected.to be_allowed(:award_emoji)
is_expected.to be_allowed(*author_permissions)
@@ -128,7 +128,7 @@ describe PersonalSnippetPolicy do
subject { permissions(nil) }
it do
- is_expected.to be_disallowed(:read_personal_snippet)
+ is_expected.to be_disallowed(:read_snippet)
is_expected.to be_disallowed(:create_note)
is_expected.to be_disallowed(:award_emoji)
is_expected.to be_disallowed(*author_permissions)
@@ -139,7 +139,7 @@ describe PersonalSnippetPolicy do
subject { permissions(regular_user) }
it do
- is_expected.to be_disallowed(:read_personal_snippet)
+ is_expected.to be_disallowed(:read_snippet)
is_expected.to be_disallowed(:create_note)
is_expected.to be_disallowed(:award_emoji)
is_expected.to be_disallowed(*author_permissions)
@@ -150,7 +150,7 @@ describe PersonalSnippetPolicy do
subject { permissions(external_user) }
it do
- is_expected.to be_disallowed(:read_personal_snippet)
+ is_expected.to be_disallowed(:read_snippet)
is_expected.to be_disallowed(:create_note)
is_expected.to be_disallowed(:award_emoji)
is_expected.to be_disallowed(*author_permissions)
@@ -161,7 +161,7 @@ describe PersonalSnippetPolicy do
subject { permissions(snippet.author) }
it do
- is_expected.to be_allowed(:read_personal_snippet)
+ is_expected.to be_allowed(:read_snippet)
is_expected.to be_allowed(:create_note)
is_expected.to be_allowed(:award_emoji)
is_expected.to be_allowed(*author_permissions)
diff --git a/spec/policies/project_policy_spec.rb b/spec/policies/project_policy_spec.rb
index e47204c774b..1a4b8315fde 100644
--- a/spec/policies/project_policy_spec.rb
+++ b/spec/policies/project_policy_spec.rb
@@ -17,7 +17,7 @@ describe ProjectPolicy do
%i[
read_project read_board read_list read_wiki read_issue
read_project_for_iids read_issue_iid read_label
- read_milestone read_project_snippet read_project_member read_note
+ read_milestone read_snippet read_project_member read_note
create_project create_issue create_note upload_file create_merge_request_in
award_emoji read_release
]
@@ -25,7 +25,7 @@ describe ProjectPolicy do
let(:base_reporter_permissions) do
%i[
- download_code fork_project create_project_snippet update_issue
+ download_code fork_project create_snippet update_issue
admin_issue admin_label admin_list read_commit_status read_build
read_container_image read_pipeline read_environment read_deployment
read_merge_request download_wiki_code read_sentry_issue
@@ -48,8 +48,8 @@ describe ProjectPolicy do
let(:base_maintainer_permissions) do
%i[
- push_to_delete_protected_branch update_project_snippet
- admin_project_snippet admin_project_member admin_note admin_wiki admin_project
+ push_to_delete_protected_branch update_snippet
+ admin_snippet admin_project_member admin_note admin_wiki admin_project
admin_commit_status admin_build admin_container_image
admin_pipeline admin_environment admin_deployment destroy_release add_cluster
daily_statistics
diff --git a/spec/policies/project_snippet_policy_spec.rb b/spec/policies/project_snippet_policy_spec.rb
index 374636874ee..b55d565a57c 100644
--- a/spec/policies/project_snippet_policy_spec.rb
+++ b/spec/policies/project_snippet_policy_spec.rb
@@ -12,8 +12,8 @@ describe ProjectSnippetPolicy do
let(:author) { other_user }
let(:author_permissions) do
[
- :update_project_snippet,
- :admin_project_snippet
+ :update_snippet,
+ :admin_snippet
]
end
@@ -26,7 +26,7 @@ describe ProjectSnippetPolicy do
end
it do
- expect_allowed(:read_project_snippet, :create_note)
+ expect_allowed(:read_snippet, :create_note)
expect_disallowed(*author_permissions)
end
end
@@ -38,8 +38,8 @@ describe ProjectSnippetPolicy do
context 'not snippet author' do
it do
- expect_allowed(:read_project_snippet, :create_note)
- expect_disallowed(:admin_project_snippet)
+ expect_allowed(:read_snippet, :create_note)
+ expect_disallowed(:admin_snippet)
end
end
end
@@ -53,7 +53,7 @@ describe ProjectSnippetPolicy do
end
it do
- expect_allowed(:read_project_snippet, :create_note)
+ expect_allowed(:read_snippet, :create_note)
expect_allowed(*author_permissions)
end
end
@@ -64,15 +64,15 @@ describe ProjectSnippetPolicy do
end
it do
- expect_allowed(:read_project_snippet, :create_note)
- expect_disallowed(:admin_project_snippet)
+ expect_allowed(:read_snippet, :create_note)
+ expect_disallowed(:admin_snippet)
end
end
context 'not a project member' do
it do
- expect_allowed(:read_project_snippet, :create_note)
- expect_disallowed(:admin_project_snippet)
+ expect_allowed(:read_snippet, :create_note)
+ expect_disallowed(:admin_snippet)
end
end
end
@@ -85,7 +85,7 @@ describe ProjectSnippetPolicy do
let(:current_user) { nil }
it do
- expect_allowed(:read_project_snippet)
+ expect_allowed(:read_snippet)
expect_disallowed(*author_permissions)
end
end
@@ -94,7 +94,7 @@ describe ProjectSnippetPolicy do
let(:current_user) { regular_user }
it do
- expect_allowed(:read_project_snippet, :create_note)
+ expect_allowed(:read_snippet, :create_note)
expect_disallowed(*author_permissions)
end
@@ -105,7 +105,7 @@ describe ProjectSnippetPolicy do
let(:current_user) { external_user }
it do
- expect_allowed(:read_project_snippet, :create_note)
+ expect_allowed(:read_snippet, :create_note)
expect_disallowed(*author_permissions)
end
@@ -115,7 +115,7 @@ describe ProjectSnippetPolicy do
end
it do
- expect_allowed(:read_project_snippet, :create_note)
+ expect_allowed(:read_snippet, :create_note)
expect_disallowed(*author_permissions)
end
end
@@ -129,7 +129,7 @@ describe ProjectSnippetPolicy do
let(:current_user) { nil }
it do
- expect_disallowed(:read_project_snippet)
+ expect_disallowed(:read_snippet)
expect_disallowed(*author_permissions)
end
end
@@ -138,7 +138,7 @@ describe ProjectSnippetPolicy do
let(:current_user) { regular_user }
it do
- expect_allowed(:read_project_snippet, :create_note)
+ expect_allowed(:read_snippet, :create_note)
expect_disallowed(*author_permissions)
end
@@ -149,7 +149,7 @@ describe ProjectSnippetPolicy do
let(:current_user) { external_user }
it do
- expect_disallowed(:read_project_snippet, :create_note)
+ expect_disallowed(:read_snippet, :create_note)
expect_disallowed(*author_permissions)
end
@@ -159,7 +159,7 @@ describe ProjectSnippetPolicy do
end
it do
- expect_allowed(:read_project_snippet, :create_note)
+ expect_allowed(:read_snippet, :create_note)
expect_disallowed(*author_permissions)
end
end
@@ -173,7 +173,7 @@ describe ProjectSnippetPolicy do
let(:current_user) { nil }
it do
- expect_disallowed(:read_project_snippet)
+ expect_disallowed(:read_snippet)
expect_disallowed(*author_permissions)
end
end
@@ -182,7 +182,7 @@ describe ProjectSnippetPolicy do
let(:current_user) { regular_user }
it do
- expect_disallowed(:read_project_snippet, :create_note)
+ expect_disallowed(:read_snippet, :create_note)
expect_disallowed(*author_permissions)
end
@@ -193,7 +193,7 @@ describe ProjectSnippetPolicy do
let(:current_user) { external_user }
it do
- expect_disallowed(:read_project_snippet, :create_note)
+ expect_disallowed(:read_snippet, :create_note)
expect_disallowed(*author_permissions)
end
@@ -203,7 +203,7 @@ describe ProjectSnippetPolicy do
end
it do
- expect_allowed(:read_project_snippet, :create_note)
+ expect_allowed(:read_snippet, :create_note)
expect_disallowed(*author_permissions)
end
end
@@ -214,7 +214,7 @@ describe ProjectSnippetPolicy do
let(:current_user) { create(:admin) }
it do
- expect_allowed(:read_project_snippet, :create_note)
+ expect_allowed(:read_snippet, :create_note)
expect_allowed(*author_permissions)
end
end