diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-01-11 12:03:33 +0000 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2018-01-15 13:28:29 -0600 |
commit | 72e905d425b1dada108d4d018a4bc1f79ec8b28a (patch) | |
tree | 85751d391463d7d90b6eb648b99eb122d0d6bbb8 | |
parent | da5efa5b83d2cb35a347df54e9433a1558b410ca (diff) | |
download | gitlab-ce-72e905d425b1dada108d4d018a4bc1f79ec8b28a.tar.gz |
Merge branch 'Ben305/gitlab-ce-36669-default-mr-title-with-external-issues' into 'master'
Resolve "Incorrect default merge request title when Jira activated"
Closes #36669
See merge request gitlab-org/gitlab-ce!16356
-rw-r--r-- | app/services/merge_requests/build_service.rb | 8 | ||||
-rw-r--r-- | changelogs/unreleased/36669-default-mr-title-with-external-issues.yml | 5 | ||||
-rw-r--r-- | spec/services/merge_requests/build_service_spec.rb | 26 |
3 files changed, 31 insertions, 8 deletions
diff --git a/app/services/merge_requests/build_service.rb b/app/services/merge_requests/build_service.rb index 9622a5c5462..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 "Resolve #{issue.title}" - end + merge_request.title = "Resolve \"#{issue.title}\"" end def issue_iid diff --git a/changelogs/unreleased/36669-default-mr-title-with-external-issues.yml b/changelogs/unreleased/36669-default-mr-title-with-external-issues.yml new file mode 100644 index 00000000000..6af9ac4b099 --- /dev/null +++ b/changelogs/unreleased/36669-default-mr-title-with-external-issues.yml @@ -0,0 +1,5 @@ +--- +title: Default merge request title is set correctly again when external issue tracker is activated +merge_request: 16356 +author: Ben305 +type: fixed diff --git a/spec/services/merge_requests/build_service_spec.rb b/spec/services/merge_requests/build_service_spec.rb index a9605c6e4c6..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 @@ -241,8 +259,12 @@ describe MergeRequests::BuildService do allow(project).to receive(:external_issue_tracker).and_return(true) end - it 'sets the title to: Resolves External Issue $issue-iid' do - expect(merge_request.title).to eq('Resolve External Issue 12345') + 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 |