Commit 3ff8a013 authored by Markus Koller's avatar Markus Koller

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

Fix force_remove_source_branch not working in API

See merge request gitlab-org/gitlab!33804
parents 058692fa e175d2a1
---
title: Fix force_remove_source_branch not working in API
merge_request: 33804
author:
type: fixed
......@@ -477,7 +477,7 @@ module API
squash_commit_message: params[:squash_commit_message],
should_remove_source_branch: params[:should_remove_source_branch],
sha: params[:sha] || merge_request.diff_head_sha
)
).compact
if immediately_mergeable
::MergeRequests::MergeService
......
......@@ -2029,6 +2029,34 @@ describe API::MergeRequests do
end
end
context "with a merge request that has force_remove_source_branch enabled" do
let(:source_repository) { merge_request.source_project.repository }
let(:source_branch) { merge_request.source_branch }
before do
merge_request.update(merge_params: { 'force_remove_source_branch' => true })
end
it 'removes the source branch' do
put(
api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user)
)
expect(response).to have_gitlab_http_status(:ok)
expect(source_repository.branch_exists?(source_branch)).to be_falsy
end
it 'does not remove the source branch' do
put(
api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user),
params: { should_remove_source_branch: false }
)
expect(response).to have_gitlab_http_status(:ok)
expect(source_repository.branch_exists?(source_branch)).to be_truthy
end
end
context "performing a ff-merge with squash" do
let(:merge_request) { create(:merge_request, :rebased, source_project: project, squash: true) }
......
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