summaryrefslogtreecommitdiff
path: root/spec/services
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-02-12 17:29:28 -0800
committerStan Hu <stanhu@gmail.com>2018-02-12 17:34:18 -0800
commit926002fdf8d83147cfb577939bd3f8e75da56548 (patch)
treeb1148e6455a6b2d7a03d80eb463416444565503a /spec/services
parent498ade4801a822f8704390b10d178af9fe7987cb (diff)
downloadgitlab-ce-926002fdf8d83147cfb577939bd3f8e75da56548.tar.gz
Fix Error 500s creating merge requests with external issue trackersh-fix-issue-43193
When JIRA or Redmine were enabled and the branch name did not match the matching regular expression, the `issue_iid` would be `nil`, preventing users from creating merge requests. Closes #43193
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/merge_requests/build_service_spec.rb32
1 files changed, 21 insertions, 11 deletions
diff --git a/spec/services/merge_requests/build_service_spec.rb b/spec/services/merge_requests/build_service_spec.rb
index e56d335a7d6..a0d0a4fd81b 100644
--- a/spec/services/merge_requests/build_service_spec.rb
+++ b/spec/services/merge_requests/build_service_spec.rb
@@ -286,33 +286,43 @@ describe MergeRequests::BuildService do
end
end
- context 'branch starts with JIRA-formatted external issue IID' do
- let(:source_branch) { 'EXMPL-12345' }
-
+ describe 'with JIRA enabled' do
before do
allow(project).to receive(:external_issue_tracker).and_return(true)
allow(project).to receive(:issues_enabled?).and_return(false)
allow(project).to receive(:external_issue_reference_pattern).and_return(IssueTrackerService.reference_pattern)
end
- it 'sets the title to the humanized branch title' do
- expect(merge_request.title).to eq('Resolve EXMPL-12345')
- end
+ context 'branch does not start with JIRA-formatted external issue IID' do
+ let(:source_branch) { 'test-branch' }
- it 'appends the closes text' do
- expect(merge_request.description).to eq('Closes EXMPL-12345')
+ it 'sets the title to the humanized branch title' do
+ expect(merge_request.title).to eq('Test branch')
+ end
end
- context 'followed by hyphenated text' do
- let(:source_branch) { 'EXMPL-12345-fix-issue' }
+ context 'branch starts with JIRA-formatted external issue IID' do
+ let(:source_branch) { 'EXMPL-12345' }
it 'sets the title to the humanized branch title' do
- expect(merge_request.title).to eq('Resolve EXMPL-12345 "Fix issue"')
+ expect(merge_request.title).to eq('Resolve EXMPL-12345')
end
it 'appends the closes text' do
expect(merge_request.description).to eq('Closes EXMPL-12345')
end
+
+ context 'followed by hyphenated text' do
+ let(:source_branch) { 'EXMPL-12345-fix-issue' }
+
+ it 'sets the title to the humanized branch title' do
+ expect(merge_request.title).to eq('Resolve EXMPL-12345 "Fix issue"')
+ end
+
+ it 'appends the closes text' do
+ expect(merge_request.description).to eq('Closes EXMPL-12345')
+ end
+ end
end
end
end