diff options
author | Sebastian Ziebell <sebastian.ziebell@asquera.de> | 2013-02-06 15:03:05 +0100 |
---|---|---|
committer | Sebastian Ziebell <sebastian.ziebell@asquera.de> | 2013-02-06 17:10:29 +0100 |
commit | 5be0265fe7e82a127e9fd2805e81e4e40f5e3c5f (patch) | |
tree | 84b2cf93fd19aa260347cda54e521fb9e6b9a9e5 /lib/api/milestones.rb | |
parent | 41e93bbfe23b3791d1b440dd3961d4fadfbb8461 (diff) | |
download | gitlab-ce-5be0265fe7e82a127e9fd2805e81e4e40f5e3c5f.tar.gz |
Status code 400 returned if title not given in a milestone (via API)
If a milestone is created via API but no title given then status code 400 (Bad request)
is returned instead of 404. A small helper method handles the errors collection of a
milestone.
Diffstat (limited to 'lib/api/milestones.rb')
-rw-r--r-- | lib/api/milestones.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/api/milestones.rb b/lib/api/milestones.rb index 6aca9d01b09..1f7d0876120 100644 --- a/lib/api/milestones.rb +++ b/lib/api/milestones.rb @@ -4,6 +4,20 @@ module Gitlab before { authenticate! } resource :projects do + + helpers do + # If an error occurs this helper method handles error codes for a given milestone + # + # Parameters: + # milestone_errors (required) - The erros collection of a milestone + # + def handle_milestone_errors(milestone_errors) + if milestone_errors[:title].any? + error!(milestone_errors[:title], 400) + end + end + end + # Get a list of project milestones # # Parameters: @@ -47,6 +61,7 @@ module Gitlab if @milestone.save present @milestone, with: Entities::Milestone else + handle_milestone_errors(@milestone.errors) not_found! end end @@ -70,6 +85,7 @@ module Gitlab if @milestone.update_attributes attrs present @milestone, with: Entities::Milestone else + handle_milestone_errors(@milestone.errors) not_found! end end |