summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Schilling <rschilling@student.tugraz.at>2016-11-30 17:12:43 +0100
committerRobert Schilling <rschilling@student.tugraz.at>2016-12-13 09:01:48 +0100
commit2cbd07e69c647726cfb927bf35a594850d4f22fa (patch)
tree218f294d4b02fe2fce9f31b99e56ae1962b4312a
parentdb9e1635d0d17596193ecbee8e0acc1916918d1d (diff)
downloadgitlab-ce-api-dont-allow-blank-mr-titles.tar.gz
Don't allow blank MR titles in APIapi-dont-allow-blank-mr-titles
-rw-r--r--lib/api/merge_requests.rb4
-rw-r--r--spec/requests/api/merge_requests_spec.rb16
2 files changed, 18 insertions, 2 deletions
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb
index 55bdbc6a47c..5d1fe22f2df 100644
--- a/lib/api/merge_requests.rb
+++ b/lib/api/merge_requests.rb
@@ -143,8 +143,8 @@ module API
success Entities::MergeRequest
end
params do
- optional :title, type: String, desc: 'The title of the merge request'
- optional :target_branch, type: String, desc: 'The target branch'
+ optional :title, type: String, allow_blank: false, desc: 'The title of the merge request'
+ optional :target_branch, type: String, allow_blank: false, desc: 'The target branch'
optional :state_event, type: String, values: %w[close reopen merge],
desc: 'Status of the merge request'
use :optional_params
diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb
index 75b270aa93c..f032d1b683d 100644
--- a/spec/requests/api/merge_requests_spec.rb
+++ b/spec/requests/api/merge_requests_spec.rb
@@ -533,6 +533,22 @@ describe API::MergeRequests, api: true do
expect(json_response['labels']).to include '?'
expect(json_response['labels']).to include '&'
end
+
+ it 'does not update state when title is empty' do
+ put api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user), state_event: 'close', title: nil
+
+ merge_request.reload
+ expect(response).to have_http_status(400)
+ expect(merge_request.state).to eq('opened')
+ end
+
+ it 'does not update state when target_branch is empty' do
+ put api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user), state_event: 'close', target_branch: nil
+
+ merge_request.reload
+ expect(response).to have_http_status(400)
+ expect(merge_request.state).to eq('opened')
+ end
end
describe "POST /projects/:id/merge_requests/:merge_request_id/comments" do