From ba21c00f01bf4274d0e4cc3892293fc1e581b260 Mon Sep 17 00:00:00 2001 From: Robert Schilling Date: Wed, 6 Apr 2016 01:21:02 +0200 Subject: Delete notes via API --- lib/api/notes.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lib') diff --git a/lib/api/notes.rb b/lib/api/notes.rb index 174473f5371..fd1704d395c 100644 --- a/lib/api/notes.rb +++ b/lib/api/notes.rb @@ -112,6 +112,23 @@ module API end end + # Delete a +notable+ note + # + # Parameters: + # Parameters: + # id (required) - The ID of a project + # noteable_id (required) - The ID of an issue, MR, or snippet + # node_id (required) - The ID of a note + # Example Request: + # DELETE /projects/:id/issues/:noteable_id/notes/:note_id + # DELETE /projects/:id/snippets/:noteable_id/notes/:node_id + delete ":id/#{noteables_str}/:#{noteable_id_str}/notes/:note_id" do + note = user_project.notes.find(params[:note_id]) + not_found!('Note') unless note + authorize! :admin_note, note + ::Notes::DeleteService.new(user_project, current_user).execute(note) + true + end end end end -- cgit v1.2.1 From 9aefaa41ab1442f81ffc15ad9a8279bd1e92c91a Mon Sep 17 00:00:00 2001 From: Robert Schilling Date: Wed, 6 Apr 2016 19:04:17 +0200 Subject: Fix code review issues --- lib/api/notes.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/api/notes.rb b/lib/api/notes.rb index fd1704d395c..2ed986b9ec5 100644 --- a/lib/api/notes.rb +++ b/lib/api/notes.rb @@ -112,10 +112,9 @@ module API end end - # Delete a +notable+ note + # Delete a +noteable+ note # # Parameters: - # Parameters: # id (required) - The ID of a project # noteable_id (required) - The ID of an issue, MR, or snippet # node_id (required) - The ID of a note @@ -124,10 +123,9 @@ module API # DELETE /projects/:id/snippets/:noteable_id/notes/:node_id delete ":id/#{noteables_str}/:#{noteable_id_str}/notes/:note_id" do note = user_project.notes.find(params[:note_id]) - not_found!('Note') unless note authorize! :admin_note, note ::Notes::DeleteService.new(user_project, current_user).execute(note) - true + present note, with: Entities::Note end end end -- cgit v1.2.1 From dc39c8372d760eceba50a35505dad8663b9e851e Mon Sep 17 00:00:00 2001 From: Robert Schilling Date: Tue, 12 Apr 2016 15:43:29 +0200 Subject: Adapt tests to new testing guidelines --- lib/api/notes.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib') diff --git a/lib/api/notes.rb b/lib/api/notes.rb index 2ed986b9ec5..a1c98f5e8ff 100644 --- a/lib/api/notes.rb +++ b/lib/api/notes.rb @@ -124,7 +124,9 @@ module API delete ":id/#{noteables_str}/:#{noteable_id_str}/notes/:note_id" do note = user_project.notes.find(params[:note_id]) authorize! :admin_note, note + ::Notes::DeleteService.new(user_project, current_user).execute(note) + present note, with: Entities::Note end end -- cgit v1.2.1