summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2019-02-25 15:47:35 +0000
committerLin Jen-Shin <godfat@godfat.org>2019-02-25 15:47:35 +0000
commit5a0629b483017146eb568b4c6f2ce8397ed1db53 (patch)
tree56e17d15bf2d1f6c8be2949b5578afa71ef683a2
parent4441def02383a085b96c0d45ba522b2a372c2275 (diff)
parentc85a768ca5d8c53b7770fdc4dc8f9eeef237b8c8 (diff)
downloadgitlab-ce-5a0629b483017146eb568b4c6f2ce8397ed1db53.tar.gz
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
-rw-r--r--changelogs/unreleased/58020-fix-merge-api-endpoint-param.yml5
-rw-r--r--lib/api/merge_requests.rb4
-rw-r--r--spec/requests/api/merge_requests_spec.rb15
3 files changed, 22 insertions, 2 deletions
diff --git a/changelogs/unreleased/58020-fix-merge-api-endpoint-param.yml b/changelogs/unreleased/58020-fix-merge-api-endpoint-param.yml
new file mode 100644
index 00000000000..7cfeb4a0cd7
--- /dev/null
+++ b/changelogs/unreleased/58020-fix-merge-api-endpoint-param.yml
@@ -0,0 +1,5 @@
+---
+title: Respect the should_remove_source_branch parameter to the merge API
+merge_request: 25525
+author:
+type: fixed
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb
index f8d2ba49d2f..03f6684226f 100644
--- a/lib/api/merge_requests.rb
+++ b/lib/api/merge_requests.rb
@@ -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
diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb
index b8426126bc6..b4cd3130dc5 100644
--- a/spec/requests/api/merge_requests_spec.rb
+++ b/spec/requests/api/merge_requests_spec.rb
@@ -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