Commit aa261c81 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'sh-fix-issue-51220' into 'master'

Handle force_remove_source_branch when creating merge request

Closes #51220

See merge request gitlab-org/gitlab-ce!23281
parents 7d1bc0be 4c4c8532
......@@ -10,6 +10,7 @@ module MergeRequests
# TODO: this should handle all quick actions that don't have side effects
# https://gitlab.com/gitlab-org/gitlab-ce/issues/53658
merge_quick_actions_into_params!(merge_request, only: [:target_branch])
merge_request.merge_params['force_remove_source_branch'] = params.delete(:force_remove_source_branch) if params.has_key?(:force_remove_source_branch)
merge_request.assign_attributes(params)
merge_request.author = current_user
......
---
title: Handle force_remove_source_branch when creating merge request
merge_request: 23281
author:
type: fixed
......@@ -21,15 +21,20 @@ describe MergeRequests::BuildService do
let(:commit_2) { double(:commit_2, sha: 'f00ba7', safe_message: 'This is a bad commit message!') }
let(:commits) { nil }
let(:params) do
{
description: description,
source_branch: source_branch,
target_branch: target_branch,
source_project: source_project,
target_project: target_project,
milestone_id: milestone_id,
label_ids: label_ids
}
end
let(:service) do
described_class.new(project, user,
description: description,
source_branch: source_branch,
target_branch: target_branch,
source_project: source_project,
target_project: target_project,
milestone_id: milestone_id,
label_ids: label_ids)
described_class.new(project, user, params)
end
before do
......@@ -56,6 +61,19 @@ describe MergeRequests::BuildService do
merge_request
end
it 'does not assign force_remove_source_branch' do
expect(merge_request.force_remove_source_branch?).to be_falsey
end
context 'with force_remove_source_branch parameter' do
let(:mr_params) { params.merge(force_remove_source_branch: '1') }
let(:merge_request) { described_class.new(project, user, mr_params).execute }
it 'assigns force_remove_source_branch' do
expect(merge_request.force_remove_source_branch?).to be_truthy
end
end
context 'missing source branch' do
let(:source_branch) { '' }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment