Commit 270a43370a4cd9e5f222ad707f68f42088d5ae06

Authored by Nihad Abbasov
1 parent b17e94c3

API: get a single wall note

doc/api/notes.md
... ... @@ -57,6 +57,19 @@ Parameters:
57 57  
58 58 ## Single note
59 59  
  60 +### Single wall note
  61 +
  62 +Get a wall note.
  63 +
  64 +```
  65 +GET /projects/:id/notes/:note_id
  66 +```
  67 +
  68 +Parameters:
  69 +
  70 ++ `id` (required) - The ID or code name of a project
  71 ++ `note_id` (required) - The ID of a wall note
  72 +
60 73 ### Single issue note
61 74  
62 75 Get an issue note.
... ...
lib/api/notes.rb
... ... @@ -17,6 +17,18 @@ module Gitlab
17 17 present paginate(@notes), with: Entities::Note
18 18 end
19 19  
  20 + # Get a single project wall note
  21 + #
  22 + # Parameters:
  23 + # id (required) - The ID or code name of a project
  24 + # note_id (required) - The ID of a note
  25 + # Example Request:
  26 + # GET /projects/:id/notes/:note_id
  27 + get ":id/notes/:note_id" do
  28 + @note = user_project.common_notes.find(params[:note_id])
  29 + present @note, with: Entities::Note
  30 + end
  31 +
20 32 # Create a new project wall note
21 33 #
22 34 # Parameters:
... ...
spec/requests/api/notes_spec.rb
... ... @@ -30,6 +30,14 @@ describe Gitlab::API do
30 30 end
31 31 end
32 32  
  33 + describe "GET /projects/:id/notes/:note_id" do
  34 + it "should return a wall note by id" do
  35 + get api("/projects/#{project.id}/notes/#{wall_note.id}", user)
  36 + response.status.should == 200
  37 + json_response['body'].should == wall_note.note
  38 + end
  39 + end
  40 +
33 41 describe "POST /projects/:id/notes" do
34 42 it "should create a new wall note" do
35 43 post api("/projects/#{project.id}/notes", user), body: 'hi!'
... ...