Commit 5a0629b4 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch '58020-fix-merge-api-endpoint-param' into 'master'

Respect the `should_remove_source_branch` parameter to the merge API

Closes #58020

See merge request gitlab-org/gitlab-ce!25525
parents 4441def0 c85a768c
---
title: Respect the should_remove_source_branch parameter to the merge API
merge_request: 25525
author:
type: fixed
......@@ -369,11 +369,11 @@ module API
merge_request.update(squash: params[:squash]) if params[:squash]
merge_params = {
merge_params = HashWithIndifferentAccess.new(
commit_message: params[:merge_commit_message],
squash_commit_message: params[:squash_commit_message],
should_remove_source_branch: params[:should_remove_source_branch]
}
)
if merge_when_pipeline_succeeds && merge_request.head_pipeline && merge_request.head_pipeline.active?
::MergeRequests::MergeWhenPipelineSucceedsService
......
......@@ -984,6 +984,21 @@ describe API::MergeRequests do
expect(squash_commit.message).to eq(merge_request.default_squash_commit_message)
end
end
describe "the should_remove_source_branch param" do
let(:source_repository) { merge_request.source_project.repository }
let(:source_branch) { merge_request.source_branch }
it 'removes the source branch when set' do
put(
api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user),
params: { should_remove_source_branch: true }
)
expect(response).to have_gitlab_http_status(200)
expect(source_repository.branch_exists?(source_branch)).to be_falsy
end
end
end
describe "PUT /projects/:id/merge_requests/:merge_request_iid" do
......
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