diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-07-24 13:00:33 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-07-24 13:00:33 +0000 |
commit | 6d13bc5863ca4ac6c06ba544e3d13e722984a65e (patch) | |
tree | 56f988dbb19a917e345cc51a55a93cd7ce1d543a /spec/services | |
parent | 7eaef13093fcd2d6794b056519c461499f690ea8 (diff) | |
parent | 6774a0378d624fafbd287ce4adcee3787106f1b9 (diff) | |
download | gitlab-ce-6d13bc5863ca4ac6c06ba544e3d13e722984a65e.tar.gz |
Merge branch '33097-issue-tracker' into 'master'
Associate Issues tab only with internal issues tracker
Closes #33097
See merge request !12130
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/git_push_service_spec.rb | 58 | ||||
-rw-r--r-- | spec/services/issues/close_service_spec.rb | 8 | ||||
-rw-r--r-- | spec/services/merge_requests/build_service_spec.rb | 2 |
3 files changed, 52 insertions, 16 deletions
diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb index c493c08a7ae..f801506f1b6 100644 --- a/spec/services/git_push_service_spec.rb +++ b/spec/services/git_push_service_spec.rb @@ -488,21 +488,57 @@ describe GitPushService, services: true do end end - context "using wrong markdown" do - let(:message) { "this is some work.\n\ncloses #1" } + context "using internal issue reference" do + context 'when internal issues are disabled' do + before do + project.issues_enabled = false + project.save! + end + let(:message) { "this is some work.\n\ncloses #1" } + + it "does not initiates one api call to jira server to close the issue" do + execute_service(project, commit_author, @oldrev, @newrev, @ref ) + + expect(WebMock).not_to have_requested(:post, jira_api_transition_url('JIRA-1')) + end + + it "does not initiates one api call to jira server to comment on the issue" do + execute_service(project, commit_author, @oldrev, @newrev, @ref ) + + expect(WebMock).not_to have_requested(:post, jira_api_comment_url('JIRA-1')).with( + body: comment_body + ).once + end + end - it "does not initiates one api call to jira server to close the issue" do - execute_service(project, commit_author, @oldrev, @newrev, @ref ) + context 'when internal issues are enabled' do + let(:issue) { create(:issue, project: project) } + let(:message) { "this is some work.\n\ncloses JIRA-1 \n\n closes #{issue.to_reference}" } - expect(WebMock).not_to have_requested(:post, jira_api_transition_url('JIRA-1')) - end + it "initiates one api call to jira server to close the jira issue" do + execute_service(project, commit_author, @oldrev, @newrev, @ref ) - it "does not initiates one api call to jira server to comment on the issue" do - execute_service(project, commit_author, @oldrev, @newrev, @ref ) + expect(WebMock).to have_requested(:post, jira_api_transition_url('JIRA-1')).once + end - expect(WebMock).not_to have_requested(:post, jira_api_comment_url('JIRA-1')).with( - body: comment_body - ).once + it "initiates one api call to jira server to comment on the jira issue" do + execute_service(project, commit_author, @oldrev, @newrev, @ref ) + + expect(WebMock).to have_requested(:post, jira_api_comment_url('JIRA-1')).with( + body: comment_body + ).once + end + + it "closes the internal issue" do + execute_service(project, commit_author, @oldrev, @newrev, @ref ) + expect(issue.reload).to be_closed + end + + it "adds a note indicating that the issue is now closed" do + expect(SystemNoteService).to receive(:change_status) + .with(issue, project, commit_author, "closed", closing_commit) + execute_service(project, commit_author, @oldrev, @newrev, @ref ) + end end end end diff --git a/spec/services/issues/close_service_spec.rb b/spec/services/issues/close_service_spec.rb index d6f4c694069..da8b60f1337 100644 --- a/spec/services/issues/close_service_spec.rb +++ b/spec/services/issues/close_service_spec.rb @@ -98,13 +98,13 @@ describe Issues::CloseService, services: true do end end - context 'external issue tracker' do + context 'internal issues disabled' do before do - allow(project).to receive(:default_issues_tracker?).and_return(false) - described_class.new(project, user).close_issue(issue) + project.issues_enabled = false + project.save! end - it 'closes the issue' do + it 'does not close the issue' do expect(issue).to be_valid expect(issue).to be_opened expect(todo.reload).to be_pending diff --git a/spec/services/merge_requests/build_service_spec.rb b/spec/services/merge_requests/build_service_spec.rb index 01ef52396d7..a40d4c877bc 100644 --- a/spec/services/merge_requests/build_service_spec.rb +++ b/spec/services/merge_requests/build_service_spec.rb @@ -207,7 +207,7 @@ describe MergeRequests::BuildService, services: true do let(:source_branch) { '12345-fix-issue' } before do - allow(project).to receive(:default_issues_tracker?).and_return(false) + allow(project).to receive(:external_issue_tracker).and_return(true) end it 'sets the title to: Resolves External Issue $issue-iid' do |