diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/services/merge_requests/build_service_spec.rb | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/spec/services/merge_requests/build_service_spec.rb b/spec/services/merge_requests/build_service_spec.rb index 7ad13478dd4..87aebae3e9b 100644 --- a/spec/services/merge_requests/build_service_spec.rb +++ b/spec/services/merge_requests/build_service_spec.rb @@ -5,7 +5,7 @@ describe MergeRequests::BuildService, services: true do let(:project) { create(:project) } let(:user) { create(:user) } - let(:issue) { create(:issue, project: project) } + let(:issue) { create(:issue, project: project, title: 'A bug') } let(:description) { nil } let(:source_branch) { 'feature-branch' } let(:target_branch) { 'master' } @@ -141,6 +141,32 @@ describe MergeRequests::BuildService, services: true do expect(merge_request.description).to eq(description) end end + + context 'branch starts with GitLab issue IID followed by a hyphen' do + let(:source_branch) { "#{issue.iid}-fix-issue" } + + it 'sets the title to: Resolves "$issue-title"' do + expect(merge_request.title).to eq("Resolves \"#{issue.title}\"") + end + + context 'issue does not exist' do + let(:source_branch) { "#{issue.iid.succ}-fix-issue" } + + it 'uses the title of the branch as the merge request title' do + expect(merge_request.title).to eq("#{issue.iid.succ} fix issue") + end + end + end + + context 'branch starts with external issue IID followed by a hyphen' do + let(:source_branch) { '12345-fix-issue' } + + before { allow(project).to receive(:default_issues_tracker?).and_return(false) } + + it 'sets the title to: Resolves External Issue $issue-iid' do + expect(merge_request.title).to eq('Resolves External Issue 12345') + end + end end end end |