summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorFelipe Artur <felipefac@gmail.com>2017-06-14 17:38:27 -0300
committerFelipe Artur <felipefac@gmail.com>2017-06-16 16:33:09 -0300
commitc4720170786d8a16eccfffb12efd5887a5cf69b5 (patch)
treef3bf17b5dd337affe3149e09f077a2344190a3f9 /spec
parent43e1481c8191651880fe20ff2b07a5501a5f7112 (diff)
downloadgitlab-ce-c4720170786d8a16eccfffb12efd5887a5cf69b5.tar.gz
Fix API bug accepting wrong merge requests parametersissue_33205
Diffstat (limited to 'spec')
-rw-r--r--spec/requests/api/merge_requests_spec.rb26
1 files changed, 23 insertions, 3 deletions
diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb
index 16e5efb2f5b..452ff4aba8e 100644
--- a/spec/requests/api/merge_requests_spec.rb
+++ b/spec/requests/api/merge_requests_spec.rb
@@ -334,14 +334,13 @@ describe API::MergeRequests do
target_branch: 'master',
author: user,
labels: 'label, label2',
- milestone_id: milestone.id,
- remove_source_branch: true
+ milestone_id: milestone.id
expect(response).to have_http_status(201)
expect(json_response['title']).to eq('Test merge_request')
expect(json_response['labels']).to eq(%w(label label2))
expect(json_response['milestone']['id']).to eq(milestone.id)
- expect(json_response['force_remove_source_branch']).to be_truthy
+ expect(json_response['force_remove_source_branch']).to be_falsy
end
it "returns 422 when source_branch equals target_branch" do
@@ -404,6 +403,27 @@ describe API::MergeRequests do
expect(response).to have_http_status(409)
end
end
+
+ context 'accepts remove_source_branch parameter' do
+ let(:params) do
+ { title: 'Test merge_request',
+ source_branch: 'markdown',
+ target_branch: 'master',
+ author: user }
+ end
+
+ it 'sets force_remove_source_branch to false' do
+ post api("/projects/#{project.id}/merge_requests", user), params.merge(remove_source_branch: false)
+
+ expect(json_response['force_remove_source_branch']).to be_falsy
+ end
+
+ it 'sets force_remove_source_branch to true' do
+ post api("/projects/#{project.id}/merge_requests", user), params.merge(remove_source_branch: true)
+
+ expect(json_response['force_remove_source_branch']).to be_truthy
+ end
+ end
end
context 'forked projects' do