From 270a43370a4cd9e5f222ad707f68f42088d5ae06 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Sat, 1 Dec 2012 02:20:45 -0800 Subject: [PATCH] API: get a single wall note --- doc/api/notes.md | 13 +++++++++++++ lib/api/notes.rb | 12 ++++++++++++ spec/requests/api/notes_spec.rb | 8 ++++++++ 3 files changed, 33 insertions(+) diff --git a/doc/api/notes.md b/doc/api/notes.md index 97899fa0..7b226dea 100644 --- a/doc/api/notes.md +++ b/doc/api/notes.md @@ -57,6 +57,19 @@ Parameters: ## Single note +### Single wall note + +Get a wall note. + +``` +GET /projects/:id/notes/:note_id +``` + +Parameters: + ++ `id` (required) - The ID or code name of a project ++ `note_id` (required) - The ID of a wall note + ### Single issue note Get an issue note. diff --git a/lib/api/notes.rb b/lib/api/notes.rb index b47ff5c3..a3e18584 100644 --- a/lib/api/notes.rb +++ b/lib/api/notes.rb @@ -17,6 +17,18 @@ module Gitlab present paginate(@notes), with: Entities::Note end + # Get a single project wall note + # + # Parameters: + # id (required) - The ID or code name of a project + # note_id (required) - The ID of a note + # Example Request: + # GET /projects/:id/notes/:note_id + get ":id/notes/:note_id" do + @note = user_project.common_notes.find(params[:note_id]) + present @note, with: Entities::Note + end + # Create a new project wall note # # Parameters: diff --git a/spec/requests/api/notes_spec.rb b/spec/requests/api/notes_spec.rb index dc02e7a3..681ba015 100644 --- a/spec/requests/api/notes_spec.rb +++ b/spec/requests/api/notes_spec.rb @@ -30,6 +30,14 @@ describe Gitlab::API do end end + describe "GET /projects/:id/notes/:note_id" do + it "should return a wall note by id" do + get api("/projects/#{project.id}/notes/#{wall_note.id}", user) + response.status.should == 200 + json_response['body'].should == wall_note.note + 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!'