Merge branch 'api-dont-allow-blank-mr-titles' into 'master'
Don't allow blank MR titles in API Closes #25033 See merge request !7848
This commit is contained in:
commit
a9da7e60ef
2 changed files with 18 additions and 2 deletions
|
@ -143,8 +143,8 @@ module API
|
||||||
success Entities::MergeRequest
|
success Entities::MergeRequest
|
||||||
end
|
end
|
||||||
params do
|
params do
|
||||||
optional :title, type: String, desc: 'The title of the merge request'
|
optional :title, type: String, allow_blank: false, desc: 'The title of the merge request'
|
||||||
optional :target_branch, type: String, desc: 'The target branch'
|
optional :target_branch, type: String, allow_blank: false, desc: 'The target branch'
|
||||||
optional :state_event, type: String, values: %w[close reopen merge],
|
optional :state_event, type: String, values: %w[close reopen merge],
|
||||||
desc: 'Status of the merge request'
|
desc: 'Status of the merge request'
|
||||||
use :optional_params
|
use :optional_params
|
||||||
|
|
|
@ -533,6 +533,22 @@ describe API::MergeRequests, api: true do
|
||||||
expect(json_response['labels']).to include '?'
|
expect(json_response['labels']).to include '?'
|
||||||
expect(json_response['labels']).to include '&'
|
expect(json_response['labels']).to include '&'
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe "POST /projects/:id/merge_requests/:merge_request_id/comments" do
|
describe "POST /projects/:id/merge_requests/:merge_request_id/comments" do
|
||||||
|
|
Loading…
Reference in a new issue