Creating or updating a MR returns more informative status codes.
Using the API library to create or update a merge request at the moment a 404 error is returned. This is fine when the merge request in question does not exist, but does not provide good information that for example a required attribute is missing. A status code of 400 (Bad request) is returned when creating or updating a merge request when either `source_branch` or `target_branch` is missing. A status code of 409 is returned when `source_branch` and `target_branch` are the same. Tests are added for these cases.
This commit is contained in:
parent
566de5ab06
commit
413952ff94
2 changed files with 44 additions and 0 deletions
|
@ -60,6 +60,13 @@ module Gitlab
|
|||
merge_request.reload_code
|
||||
present merge_request, with: Entities::MergeRequest
|
||||
else
|
||||
if merge_request.errors[:target_branch].any?
|
||||
error!(merge_request.errors[:target_branch], 400)
|
||||
elsif merge_request.errors[:source_branch].any?
|
||||
error!(merge_request.errors[:source_branch], 400)
|
||||
elsif merge_request.errors[:base].any?
|
||||
error!(merge_request.errors[:base], 422)
|
||||
end
|
||||
not_found!
|
||||
end
|
||||
end
|
||||
|
@ -88,6 +95,13 @@ module Gitlab
|
|||
merge_request.mark_as_unchecked
|
||||
present merge_request, with: Entities::MergeRequest
|
||||
else
|
||||
if merge_request.errors[:target_branch].any?
|
||||
error!(merge_request.errors[:target_branch], 400)
|
||||
elsif merge_request.errors[:source_branch].any?
|
||||
error!(merge_request.errors[:source_branch], 400)
|
||||
elsif merge_request.errors[:base].any?
|
||||
error!(merge_request.errors[:base], 422)
|
||||
end
|
||||
not_found!
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue