diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-11-29 10:01:05 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-11-29 10:01:05 +0000 |
commit | f3ac2e56e72e483da192f4aea1b464e23d56f0b4 (patch) | |
tree | 9616471a899548a9c87a23fb375b9a071a6bcde9 /spec/services | |
parent | 673c4ccbc8914a1bee0ed4fe544c06ddb000fd44 (diff) | |
parent | 5bc32b65f1257ca1f2c9fefc1e251be55b0fdc17 (diff) | |
download | gitlab-ce-f3ac2e56e72e483da192f4aea1b464e23d56f0b4.tar.gz |
Merge branch '21143-customize-branch-name-when-using-create-branch-in-an-issue' into 'master'
Resolve "Customize branch name when using create branch in an issue"
Closes #21143
See merge request gitlab-org/gitlab-ce!13884
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/merge_requests/create_from_issue_service_spec.rb | 24 |
1 files changed, 19 insertions, 5 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 313f87ae1f6..a7ab389b357 100644 --- a/spec/services/merge_requests/create_from_issue_service_spec.rb +++ b/spec/services/merge_requests/create_from_issue_service_spec.rb @@ -6,8 +6,10 @@ describe MergeRequests::CreateFromIssueService do let(:label_ids) { create_pair(:label, project: project).map(&:id) } let(:milestone_id) { create(:milestone, project: project).id } let(:issue) { create(:issue, project: project, milestone_id: milestone_id) } + let(:custom_source_branch) { 'custom-source-branch' } subject(:service) { described_class.new(project, user, issue_iid: issue.iid) } + subject(:service_with_custom_source_branch) { described_class.new(project, user, issue_iid: issue.iid, branch_name: custom_source_branch) } before do project.add_developer(user) @@ -17,8 +19,8 @@ describe MergeRequests::CreateFromIssueService do it 'returns an error with invalid issue iid' do result = described_class.new(project, user, issue_iid: -1).execute - expect(result[:status]).to eq :error - expect(result[:message]).to eq 'Invalid issue iid' + expect(result[:status]).to eq(:error) + expect(result[:message]).to eq('Invalid issue iid') end it 'delegates issue search to IssuesFinder' do @@ -53,6 +55,12 @@ describe MergeRequests::CreateFromIssueService do expect(project.repository.branch_exists?(issue.to_branch_name)).to be_truthy end + it 'creates a branch using passed name' do + service_with_custom_source_branch.execute + + expect(project.repository.branch_exists?(custom_source_branch)).to be_truthy + end + it 'creates a system note' do expect(SystemNoteService).to receive(:new_issue_branch).with(issue, project, user, issue.to_branch_name) @@ -72,19 +80,25 @@ describe MergeRequests::CreateFromIssueService do it 'sets the merge request author to current user' do result = service.execute - expect(result[:merge_request].author).to eq user + expect(result[:merge_request].author).to eq(user) end it 'sets the merge request source branch to the new issue branch' do result = service.execute - expect(result[:merge_request].source_branch).to eq issue.to_branch_name + expect(result[:merge_request].source_branch).to eq(issue.to_branch_name) + end + + it 'sets the merge request source branch to the passed branch name' do + result = service_with_custom_source_branch.execute + + expect(result[:merge_request].source_branch).to eq(custom_source_branch) end it 'sets the merge request target branch to the project default branch' do result = service.execute - expect(result[:merge_request].target_branch).to eq project.default_branch + expect(result[:merge_request].target_branch).to eq(project.default_branch) end end end |