diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-03 18:07:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-03 18:07:07 +0300 |
commit | 9a1c5456747a7b5b218b8b44e4b43396bf7fd705 (patch) | |
tree | dc5873f33437c897389e923a59365fb192d87fb8 /spec/services/issues | |
parent | 927cfbfe63dd3dc64df9d341d7c4328a2fe3597f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/issues')
-rw-r--r-- | spec/services/issues/close_service_spec.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/services/issues/close_service_spec.rb b/spec/services/issues/close_service_spec.rb index 642a49d57d5..1f7d564b6ec 100644 --- a/spec/services/issues/close_service_spec.rb +++ b/spec/services/issues/close_service_spec.rb @@ -8,6 +8,7 @@ describe Issues::CloseService do let(:user2) { create(:user, email: "user2@example.com") } let(:guest) { create(:user) } let(:issue) { create(:issue, title: "My issue", project: project, assignees: [user2], author: create(:user)) } + let(:external_issue) { ExternalIssue.new('JIRA-123', project) } let(:closing_merge_request) { create(:merge_request, source_project: project) } let(:closing_commit) { create(:commit, project: project) } let!(:todo) { create(:todo, :assigned, user: user, project: project, target: issue, author: user2) } @@ -36,6 +37,16 @@ describe Issues::CloseService do expect(service.execute(issue)).to eq(issue) end + it 'closes the external issue even when the user is not authorized to do so' do + allow(service).to receive(:can?).with(user, :update_issue, external_issue) + .and_return(false) + + expect(service).to receive(:close_issue) + .with(external_issue, closed_via: nil, notifications: true, system_note: true) + + service.execute(external_issue) + end + it 'closes the issue when the user is authorized to do so' do allow(service).to receive(:can?).with(user, :update_issue, issue) .and_return(true) |