diff options
author | Sean McGivern <sean@gitlab.com> | 2018-01-10 13:43:32 +0000 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2018-01-10 13:47:24 +0000 |
commit | ca2755619b36d11b3e25c107505aa7d99c3d8352 (patch) | |
tree | b4caa6d8ad493c7ee6dcfa8a8a1df4149e6c09e9 | |
parent | 44c8f919b4ba73fee6215ce2d6b023c666f34177 (diff) | |
download | gitlab-ce-ca2755619b36d11b3e25c107505aa7d99c3d8352.tar.gz |
Never set special MR titles for external issues
-rw-r--r-- | app/services/merge_requests/build_service.rb | 8 | ||||
-rw-r--r-- | spec/services/merge_requests/build_service_spec.rb | 22 |
2 files changed, 24 insertions, 6 deletions
diff --git a/app/services/merge_requests/build_service.rb b/app/services/merge_requests/build_service.rb index 9781fecfb50..22b9b91a957 100644 --- a/app/services/merge_requests/build_service.rb +++ b/app/services/merge_requests/build_service.rb @@ -154,13 +154,9 @@ module MergeRequests end def assign_title_from_issue - return unless issue + return unless issue && issue.is_a?(Issue) - merge_request.title = - case issue - when Issue then "Resolve \"#{issue.title}\"" - when ExternalIssue then merge_request.source_branch.titleize.humanize - end + merge_request.title = "Resolve \"#{issue.title}\"" end def issue_iid diff --git a/spec/services/merge_requests/build_service_spec.rb b/spec/services/merge_requests/build_service_spec.rb index 4b670d3530e..cb4c3e72aa0 100644 --- a/spec/services/merge_requests/build_service_spec.rb +++ b/spec/services/merge_requests/build_service_spec.rb @@ -171,6 +171,24 @@ describe MergeRequests::BuildService do end end end + + context 'branch starts with external issue IID followed by a hyphen' do + let(:source_branch) { '12345-fix-issue' } + + before do + allow(project).to receive(:external_issue_tracker).and_return(true) + end + + it 'uses the title of the commit as the title of the merge request' do + expect(merge_request.title).to eq(commit_1.safe_message.split("\n").first) + end + + it 'uses the description of the commit as the description of the merge request and appends the closes text' do + commit_description = commit_1.safe_message.split(/\n+/, 2).last + + expect(merge_request.description).to eq("#{commit_description}\n\nCloses #12345") + end + end end context 'more than one commit in the diff' do @@ -244,6 +262,10 @@ describe MergeRequests::BuildService do it 'sets the title to the humanized branch title' do expect(merge_request.title).to eq('12345 fix issue') end + + it 'appends the closes text' do + expect(merge_request.description).to eq('Closes #12345') + end end end |