diff options
author | Stan Hu <stanhu@gmail.com> | 2019-04-15 20:55:45 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-04-15 21:27:33 +0300 |
commit | d3fa9c9539aac42844a297a99ef56254ce1c06a3 (patch) | |
tree | ba94fe9d979a003585ede0c8f499030c731fa3f1 /spec/requests | |
parent | 1a50801cd0801d3134b41e96ff2a6b27a96a1047 (diff) |
Fix remove_source_branch merge request API handling
Users attempting to set merge requests to `remove_source_branch` to
`false` would encounter an Error 500 because the UpdateService and API
checked `present?`, which would always return `false`. We now just
use `has_key?` to decide whether the parameter is present.
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/60530
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/merge_requests_spec.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index 45818edbf68..5c94a87529b 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -1596,6 +1596,32 @@ describe API::MergeRequests do end describe "PUT /projects/:id/merge_requests/:merge_request_iid" do + context 'updates force_remove_source_branch properly' do + it 'sets to false' do + merge_request.update(merge_params: { 'force_remove_source_branch' => true } ) + + expect(merge_request.force_remove_source_branch?).to be_truthy + + put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { state_event: "close", remove_source_branch: false } + + expect(response).to have_gitlab_http_status(200) + expect(json_response['state']).to eq('closed') + expect(json_response['force_remove_source_branch']).to be_falsey + end + + it 'sets to true' do + merge_request.update(merge_params: { 'force_remove_source_branch' => false } ) + + expect(merge_request.force_remove_source_branch?).to be_falsey + + put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { state_event: "close", remove_source_branch: true } + + expect(response).to have_gitlab_http_status(200) + expect(json_response['state']).to eq('closed') + expect(json_response['force_remove_source_branch']).to be_truthy + end + end + context "to close a MR" do it "returns merge_request" do put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { state_event: "close" } |