summaryrefslogtreecommitdiff
path: root/lib/api/notes.rb
diff options
context:
space:
mode:
authorSebastian Ziebell <sebastian.ziebell@asquera.de>2013-02-20 22:17:05 +0100
committerSebastian Ziebell <sebastian.ziebell@asquera.de>2013-02-20 22:17:05 +0100
commit33c1463645b51bcb26932e4825df0ce8fee6c729 (patch)
tree148a9110f8696b83a77077d0350eb7a80bd92540 /lib/api/notes.rb
parentf0e417091c2cef32b560472a38f66cf6cdcaec15 (diff)
downloadgitlab-ce-33c1463645b51bcb26932e4825df0ce8fee6c729.tar.gz
API: fixes return codes for notes, documentation updated
The notes API documentation updated with return codes. API now returns `400 Bad Request` if required attributes are not present. Return codes are documented now, also tested in added tests. The documentation now reflects the current state of the API.
Diffstat (limited to 'lib/api/notes.rb')
-rw-r--r--lib/api/notes.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/api/notes.rb b/lib/api/notes.rb
index 56de6e090e5..953514b6f04 100644
--- a/lib/api/notes.rb
+++ b/lib/api/notes.rb
@@ -37,6 +37,8 @@ module Gitlab
# Example Request:
# POST /projects/:id/notes
post ":id/notes" do
+ bad_request!(:body) unless params[:body].present?
+
@note = user_project.notes.new(note: params[:body])
@note.author = current_user
@@ -91,6 +93,9 @@ module Gitlab
# POST /projects/:id/issues/:noteable_id/notes
# POST /projects/:id/snippets/:noteable_id/notes
post ":id/#{noteables_str}/:#{noteable_id_str}/notes" do
+ bad_request!(:"#{noteable_id_str}") unless params[:"#{noteable_id_str}"].present?
+ bad_request!(:body) unless params[:body].present?
+
@noteable = user_project.send(:"#{noteables_str}").find(params[:"#{noteable_id_str}"])
@note = @noteable.notes.new(note: params[:body])
@note.author = current_user