diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-14 15:07:59 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-14 15:07:59 +0300 |
commit | fd27e4f95b3ea8668e1e67f5a88dfb061909c893 (patch) | |
tree | 439bcc5417be41cd2290485292fe512f6cea8110 /spec/policies/issue_policy_spec.rb | |
parent | 6aa920eeb4ef61ea7e7c77b5e10595507874b927 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/policies/issue_policy_spec.rb')
-rw-r--r-- | spec/policies/issue_policy_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/policies/issue_policy_spec.rb b/spec/policies/issue_policy_spec.rb index 3805976b3e7..1fe9e430011 100644 --- a/spec/policies/issue_policy_spec.rb +++ b/spec/policies/issue_policy_spec.rb @@ -396,4 +396,36 @@ RSpec.describe IssuePolicy do expect(policies).to be_allowed(:read_issue_iid) end end + + describe 'set_issue_crm_contacts' do + let(:user) { create(:user) } + let(:subgroup) { create(:group, :crm_enabled, parent: create(:group, :crm_enabled)) } + let(:project) { create(:project, group: subgroup) } + let(:issue) { create(:issue, project: project) } + let(:policies) { described_class.new(user, issue) } + + context 'when project reporter' do + it 'is disallowed' do + project.add_reporter(user) + + expect(policies).to be_disallowed(:set_issue_crm_contacts) + end + end + + context 'when subgroup reporter' do + it 'is allowed' do + subgroup.add_reporter(user) + + expect(policies).to be_disallowed(:set_issue_crm_contacts) + end + end + + context 'when root group reporter' do + it 'is allowed' do + subgroup.parent.add_reporter(user) + + expect(policies).to be_allowed(:set_issue_crm_contacts) + end + end + end end |