diff options
author | Sebastian Ziebell <sebastian.ziebell@asquera.de> | 2013-02-05 17:13:47 +0100 |
---|---|---|
committer | Sebastian Ziebell <sebastian.ziebell@asquera.de> | 2013-02-06 16:57:00 +0100 |
commit | 413952ff944d10164d9d08a8a48e7725fe44b1b3 (patch) | |
tree | 617837b93a324ae8315c8a194dc335c2a03b50d5 /lib/api/merge_requests.rb | |
parent | 566de5ab06d1c29ac632d2fbd0f4440788fe1339 (diff) | |
download | gitlab-ce-413952ff944d10164d9d08a8a48e7725fe44b1b3.tar.gz |
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.
Diffstat (limited to 'lib/api/merge_requests.rb')
-rw-r--r-- | lib/api/merge_requests.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index 470cd1e1c2d..25ee8f05ba0 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -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 |