diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-01-17 09:38:44 +0000 |
---|---|---|
committer | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-01-19 14:27:00 +0000 |
commit | 41d782ed7dfaf309debea0294a09025ba2d1eb61 (patch) | |
tree | cea07713a10fe5bff65da1d46c36de1d21878496 /spec | |
parent | 593effca40dfb5a61ea97c5b571ccf5f4039d0fc (diff) | |
download | gitlab-ce-41d782ed7dfaf309debea0294a09025ba2d1eb61.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
(cherry picked from commit b4bc9bd5c5bedcd57e795f91f0668d7f2c622cde)
7e9484e9 Set target_branch to the ref branch when creating MR from issue
Diffstat (limited to 'spec')
-rw-r--r-- | spec/services/merge_requests/create_from_issue_service_spec.rb | 31 |
1 files changed, 31 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 a7ab389b357..75553afc033 100644 --- a/spec/services/merge_requests/create_from_issue_service_spec.rb +++ b/spec/services/merge_requests/create_from_issue_service_spec.rb @@ -100,5 +100,36 @@ describe MergeRequests::CreateFromIssueService do expect(result[:merge_request].target_branch).to eq(project.default_branch) end + + it 'executes quick actions if the build service sets them in the description' do + allow(service).to receive(:merge_request).and_wrap_original do |m, *args| + m.call(*args).tap do |merge_request| + merge_request.description = "/assign #{user.to_reference}" + end + end + + result = service.execute + + 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 |