Permalink
Browse files

API: ability to create a wall note

  • Loading branch information...
1 parent 2a98a06 commit ee6187bd554f6f257600a67f65f8af95cf9afa9a @NARKOZ NARKOZ committed Nov 29, 2012
Showing with 45 additions and 3 deletions.
  1. +3 −3 CHANGELOG
  2. +16 −0 doc/api/notes.md
  3. +18 −0 lib/api/notes.rb
  4. +8 −0 spec/requests/api/notes_spec.rb
View
@@ -1,7 +1,7 @@
v 3.2.0
- - [API] create notes for snippets and issues
- - [API] list notes for snippets and issues
- - [API] list project wall notes
+ - [API] list, create issue notes
+ - [API] list, create snippet notes
+ - [API] list, create wall notes
- Remove project code - use path instead
- added username field to user
- rake task to fill usernames based on emails create namespaces for users
View
@@ -87,6 +87,22 @@ Parameters:
## New note
+### New wall note
+
+Create a new wall note.
+
+```
+POST /projects/:id/notes
+```
+
+Parameters:
+
++ `id` (required) - The ID or code name of a project
++ `body` (required) - The content of a note
+
+Will return created note with status `201 Created` on success, or `404 Not found` on fail.
+
+
### New issue note
Create a new issue note.
View
@@ -17,6 +17,24 @@ class Notes < Grape::API
present paginate(@notes), with: Entities::Note
end
+ # Create a new project wall note
+ #
+ # Parameters:
+ # id (required) - The ID or code name of a project
+ # body (required) - The content of a note
+ # Example Request:
+ # POST /projects/:id/notes
+ post ":id/notes" do
+ @note = user_project.notes.new(note: params[:body])
+ @note.author = current_user
+
+ if @note.save
+ present @note, with: Entities::Note
+ else
+ not_found!
+ end
+ end
+
NOTEABLE_TYPES.each do |noteable_type|
noteables_str = noteable_type.to_s.underscore.pluralize
noteable_id_str = "#{noteable_type.to_s.underscore}_id"
@@ -30,6 +30,14 @@
end
end
+ describe "POST /projects/:id/notes" do
+ it "should create a new wall note" do
+ post api("/projects/#{project.id}/notes", user), body: 'hi!'
+ response.status.should == 201
+ json_response['body'].should == 'hi!'
+ end
+ end
+
describe "GET /projects/:id/noteable/:noteable_id/notes" do
context "when noteable is an Issue" do
it "should return an array of issue notes" do

0 comments on commit ee6187b

Please sign in to comment.