diff options
-rw-r--r-- | app/services/merge_requests/build_service.rb | 2 | ||||
-rw-r--r-- | spec/services/merge_requests/build_service_spec.rb | 11 |
2 files changed, 11 insertions, 2 deletions
diff --git a/app/services/merge_requests/build_service.rb b/app/services/merge_requests/build_service.rb index 4add1d66ea5..cd4230aa5e4 100644 --- a/app/services/merge_requests/build_service.rb +++ b/app/services/merge_requests/build_service.rb @@ -68,7 +68,7 @@ module MergeRequests commit = commits.first merge_request.title = commit.title merge_request.description ||= commit.description.try(:strip) - elsif iid && (issue = merge_request.target_project.get_issue(iid)) + elsif iid && (issue = merge_request.target_project.get_issue(iid)) && !issue.try(:confidential?) case issue when Issue merge_request.title = "Resolve \"#{issue.title}\"" diff --git a/spec/services/merge_requests/build_service_spec.rb b/spec/services/merge_requests/build_service_spec.rb index f8b768a1a9b..782d74ec5ec 100644 --- a/spec/services/merge_requests/build_service_spec.rb +++ b/spec/services/merge_requests/build_service_spec.rb @@ -5,7 +5,8 @@ describe MergeRequests::BuildService, services: true do let(:project) { create(:project) } let(:user) { create(:user) } - let(:issue) { create(:issue, project: project, title: 'A bug') } + let(:issue_confidential) { false } + let(:issue) { create(:issue, project: project, title: 'A bug', confidential: issue_confidential) } let(:description) { nil } let(:source_branch) { 'feature-branch' } let(:target_branch) { 'master' } @@ -156,6 +157,14 @@ describe MergeRequests::BuildService, services: true do expect(merge_request.title).to eq("#{issue.iid.succ} fix issue") end end + + context 'issue is confidential' do + let(:issue_confidential) { true } + + it 'uses the title of the branch as the merge request title' do + expect(merge_request.title).to eq("#{issue.iid} fix issue") + end + end end context 'branch starts with external issue IID followed by a hyphen' do |