summaryrefslogtreecommitdiff
path: root/spec/services
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2018-01-17 09:38:44 +0000
committerSean McGivern <sean@mcgivern.me.uk>2018-01-17 09:38:44 +0000
commitb4bc9bd5c5bedcd57e795f91f0668d7f2c622cde (patch)
treee779f4bae74a4731d8639b278f5672dadb9aa2b9 /spec/services
parent6b314f7b0686dc94ad9c87a3e60192b5f366447f (diff)
parent7e9484e9fab052642bc57947ce4610c164da2b9d (diff)
downloadgitlab-ce-b4bc9bd5c5bedcd57e795f91f0668d7f2c622cde.tar.gz
Merge branch '41727-target-branch-name' into 'master'
Set target_branch to the ref branch when creating MR from issue Closes #41727 See merge request gitlab-org/gitlab-ce!16422
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/merge_requests/create_from_issue_service_spec.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/services/merge_requests/create_from_issue_service_spec.rb b/spec/services/merge_requests/create_from_issue_service_spec.rb
index 623b182b205..75553afc033 100644
--- a/spec/services/merge_requests/create_from_issue_service_spec.rb
+++ b/spec/services/merge_requests/create_from_issue_service_spec.rb
@@ -112,5 +112,24 @@ describe MergeRequests::CreateFromIssueService do
expect(result[:merge_request].assignee).to eq(user)
end
+
+ context 'when ref branch is set' do
+ subject { described_class.new(project, user, issue_iid: issue.iid, ref: 'feature').execute }
+
+ it 'sets the merge request source branch to the new issue branch' do
+ expect(subject[:merge_request].source_branch).to eq(issue.to_branch_name)
+ end
+
+ it 'sets the merge request target branch to the ref branch' do
+ expect(subject[:merge_request].target_branch).to eq('feature')
+ end
+
+ context 'when ref branch does not exist' do
+ it 'does not create a merge request' do
+ expect { described_class.new(project, user, issue_iid: issue.iid, ref: 'nobr').execute }
+ .not_to change { project.merge_requests.count }
+ end
+ end
+ end
end
end