diff options
author | Gabriel Gizotti <gabriel@gizotti.com> | 2016-11-23 21:03:53 +1000 |
---|---|---|
committer | Gabriel Gizotti <gabriel@gizotti.com> | 2016-12-16 19:13:17 +1000 |
commit | e52e3ab5082599fd5a895de961b07584421a5cd2 (patch) | |
tree | cc5235f40e719a95ce48b153664f986fd6943d4f | |
parent | 49a70d1e45b4f841379db059177856671c65159c (diff) | |
download | gitlab-ce-e52e3ab5082599fd5a895de961b07584421a5cd2.tar.gz |
Remove whole description from #merge_commit_message and add add closed issues
-rw-r--r-- | app/models/merge_request.rb | 3 | ||||
-rw-r--r-- | spec/models/merge_request_spec.rb | 14 |
2 files changed, 12 insertions, 5 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index b73d7acefea..62dd02936e2 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -615,7 +615,8 @@ class MergeRequest < ActiveRecord::Base def merge_commit_message message = "Merge branch '#{source_branch}' into '#{target_branch}'\n\n" message << "#{title}\n\n" - message << "#{description}\n\n" if description.present? + mr_closes_issues = closes_issues + message << "Closed Issues: #{mr_closes_issues.map { |issue| issue.to_reference(target_project) }.join(", ")}\n\n" if mr_closes_issues.present? message << "See merge request #{to_reference}" message diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 1b71d00eb8f..e1f9d66714d 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -410,11 +410,17 @@ describe MergeRequest, models: true do .to match("Remove all technical debt\n\n") end - it 'includes its description in the body' do - request = build(:merge_request, description: 'By removing all code') + it 'includes its closed issues in the body' do + issue = create(:issue, project: subject.project) - expect(request.merge_commit_message) - .to match("By removing all code\n\n") + subject.project.team << [subject.author, :developer] + subject.description = "Closes #{issue.to_reference}" + + allow(subject.project).to receive(:default_branch). + and_return(subject.target_branch) + + expect(subject.merge_commit_message) + .to match("Closed Issues: #{issue.to_reference}") end it 'includes its reference in the body' do |