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.
This commit is contained in:
Sebastian Ziebell 2013-02-20 22:17:05 +01:00
parent f0e417091c
commit 33c1463645
3 changed files with 241 additions and 79 deletions

View file

@ -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