summaryrefslogtreecommitdiff
path: root/spec/policies/issue_policy_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/policies/issue_policy_spec.rb')
-rw-r--r--spec/policies/issue_policy_spec.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/policies/issue_policy_spec.rb b/spec/policies/issue_policy_spec.rb
index 557bda985af..fefbb59a830 100644
--- a/spec/policies/issue_policy_spec.rb
+++ b/spec/policies/issue_policy_spec.rb
@@ -13,6 +13,7 @@ RSpec.describe IssuePolicy do
let(:reporter_from_group_link) { create(:user) }
let(:non_member) { create(:user) }
let(:support_bot) { User.support_bot }
+ let(:alert_bot) { User.alert_bot }
def permissions(user, issue)
described_class.new(user, issue)
@@ -41,6 +42,14 @@ RSpec.describe IssuePolicy do
end
end
+ shared_examples 'alert bot' do
+ it 'allows alert_bot to read and set metadata on issues' do
+ expect(permissions(alert_bot, issue)).to be_allowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue, :set_issue_metadata, :set_confidentiality)
+ expect(permissions(alert_bot, issue_no_assignee)).to be_allowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue, :set_issue_metadata, :set_confidentiality)
+ expect(permissions(alert_bot, new_issue)).to be_allowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue, :set_issue_metadata, :set_confidentiality)
+ end
+ end
+
context 'a private project' do
let(:project) { create(:project, :private) }
let(:issue) { create(:issue, project: project, assignees: [assignee], author: author) }
@@ -106,6 +115,7 @@ RSpec.describe IssuePolicy do
expect(permissions(non_member, new_issue)).to be_disallowed(:create_issue, :set_issue_metadata, :set_confidentiality)
end
+ it_behaves_like 'alert bot'
it_behaves_like 'support bot with service desk disabled'
it_behaves_like 'support bot with service desk enabled'
@@ -270,6 +280,7 @@ RSpec.describe IssuePolicy do
expect(permissions(support_bot, new_issue)).to be_disallowed(:create_issue, :set_issue_metadata, :set_confidentiality)
end
+ it_behaves_like 'alert bot'
it_behaves_like 'support bot with service desk enabled'
context 'when issues are private' do
@@ -326,6 +337,7 @@ RSpec.describe IssuePolicy do
expect(permissions(non_member, new_issue)).to be_disallowed(:create_issue, :set_issue_metadata, :set_confidentiality)
end
+ it_behaves_like 'alert bot'
it_behaves_like 'support bot with service desk disabled'
it_behaves_like 'support bot with service desk enabled'
end