diff options
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/issues/close_service_spec.rb | 32 | ||||
-rw-r--r-- | spec/services/merge_requests/merge_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/system_notes/issuables_service_spec.rb | 31 |
3 files changed, 54 insertions, 11 deletions
diff --git a/spec/services/issues/close_service_spec.rb b/spec/services/issues/close_service_spec.rb index fa4e6ddb088..d8bcd8008ce 100644 --- a/spec/services/issues/close_service_spec.rb +++ b/spec/services/issues/close_service_spec.rb @@ -70,6 +70,38 @@ describe Issues::CloseService do end describe '#close_issue' do + context 'with external issue' do + context 'with an active external issue tracker supporting close_issue' do + let!(:external_issue_tracker) { create(:jira_service, project: project) } + + it 'closes the issue on the external issue tracker' do + expect(project.external_issue_tracker).to receive(:close_issue) + + described_class.new(project, user).close_issue(external_issue) + end + end + + context 'with innactive external issue tracker supporting close_issue' do + let!(:external_issue_tracker) { create(:jira_service, project: project, active: false) } + + it 'does not close the issue on the external issue tracker' do + expect(project.external_issue_tracker).not_to receive(:close_issue) + + described_class.new(project, user).close_issue(external_issue) + end + end + + context 'with an active external issue tracker not supporting close_issue' do + let!(:external_issue_tracker) { create(:bugzilla_service, project: project) } + + it 'does not close the issue on the external issue tracker' do + expect(project.external_issue_tracker).not_to receive(:close_issue) + + described_class.new(project, user).close_issue(external_issue) + end + end + end + context "closed by a merge request", :sidekiq_might_not_need_inline do it 'mentions closure via a merge request' do perform_enqueued_jobs do diff --git a/spec/services/merge_requests/merge_service_spec.rb b/spec/services/merge_requests/merge_service_spec.rb index 4d72decb632..fa7f745d8a0 100644 --- a/spec/services/merge_requests/merge_service_spec.rb +++ b/spec/services/merge_requests/merge_service_spec.rb @@ -158,7 +158,7 @@ describe MergeRequests::MergeService do end it 'does not close issue' do - allow(jira_tracker).to receive_messages(jira_issue_transition_id: nil) + jira_tracker.update(jira_issue_transition_id: nil) expect_any_instance_of(JiraService).not_to receive(:transition_issue) diff --git a/spec/services/system_notes/issuables_service_spec.rb b/spec/services/system_notes/issuables_service_spec.rb index 228d69fda4e..c0aaa65971a 100644 --- a/spec/services/system_notes/issuables_service_spec.rb +++ b/spec/services/system_notes/issuables_service_spec.rb @@ -598,8 +598,8 @@ describe ::SystemNotes::IssuablesService do context 'when mentioner is not a MergeRequest' do it 'is falsey' do mentioner = noteable.dup - expect(service.cross_reference_disallowed?(mentioner)) - .to be_falsey + + expect(service.cross_reference_disallowed?(mentioner)).to be_falsey end end @@ -609,24 +609,35 @@ describe ::SystemNotes::IssuablesService do it 'is truthy when noteable is in commits' do expect(mentioner).to receive(:commits).and_return([noteable]) - expect(service.cross_reference_disallowed?(mentioner)) - .to be_truthy + + expect(service.cross_reference_disallowed?(mentioner)).to be_truthy end it 'is falsey when noteable is not in commits' do expect(mentioner).to receive(:commits).and_return([]) - expect(service.cross_reference_disallowed?(mentioner)) - .to be_falsey + + expect(service.cross_reference_disallowed?(mentioner)).to be_falsey end end context 'when notable is an ExternalIssue' do + let(:project) { create(:project) } let(:noteable) { ExternalIssue.new('EXT-1234', project) } - it 'is truthy' do - mentioner = noteable.dup - expect(service.cross_reference_disallowed?(mentioner)) - .to be_truthy + it 'is false with issue tracker supporting referencing' do + create(:jira_service, project: project) + + expect(service.cross_reference_disallowed?(noteable)).to be_falsey + end + + it 'is true with issue tracker not supporting referencing' do + create(:bugzilla_service, project: project) + + expect(service.cross_reference_disallowed?(noteable)).to be_truthy + end + + it 'is true without issue tracker' do + expect(service.cross_reference_disallowed?(noteable)).to be_truthy end end end |