From dc39c8372d760eceba50a35505dad8663b9e851e Mon Sep 17 00:00:00 2001
From: Robert Schilling <rschilling@student.tugraz.at>
Date: Tue, 12 Apr 2016 15:43:29 +0200
Subject: [PATCH] Adapt tests to new testing guidelines

---
 lib/api/notes.rb                           |  2 ++
 spec/requests/api/notes_spec.rb            | 12 ++++++------
 spec/services/notes/delete_service_spec.rb |  9 ++++-----
 3 files changed, 12 insertions(+), 11 deletions(-)

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
diff --git a/spec/requests/api/notes_spec.rb b/spec/requests/api/notes_spec.rb
index b35e67b5bd3..a467bc935af 100644
--- a/spec/requests/api/notes_spec.rb
+++ b/spec/requests/api/notes_spec.rb
@@ -243,7 +243,7 @@ describe API::API, api: true  do
 
   describe 'DELETE /projects/:id/noteable/:noteable_id/notes/:note_id' do
     context 'when noteable is an Issue' do
-      it 'should delete a note' do
+      it 'deletes a note' do
         delete api("/projects/#{project.id}/issues/#{issue.id}/"\
                    "notes/#{issue_note.id}", user)
 
@@ -254,7 +254,7 @@ describe API::API, api: true  do
         expect(response.status).to eq(404)
       end
 
-      it 'should return a 404 error when note id not found' do
+      it 'returns a 404 error when note id not found' do
         delete api("/projects/#{project.id}/issues/#{issue.id}/notes/123", user)
 
         expect(response.status).to eq(404)
@@ -262,7 +262,7 @@ describe API::API, api: true  do
     end
 
     context 'when noteable is a Snippet' do
-      it 'should delete a note' do
+      it 'deletes a note' do
         delete api("/projects/#{project.id}/snippets/#{snippet.id}/"\
                    "notes/#{snippet_note.id}", user)
 
@@ -273,7 +273,7 @@ describe API::API, api: true  do
         expect(response.status).to eq(404)
       end
 
-      it 'should return a 404 error when note id not found' do
+      it 'returns a 404 error when note id not found' do
         delete api("/projects/#{project.id}/snippets/#{snippet.id}/"\
                    "notes/123", user)
 
@@ -282,7 +282,7 @@ describe API::API, api: true  do
     end
 
     context 'when noteable is a Merge Request' do
-      it 'should delete a note' do
+      it 'deletes a note' do
         delete api("/projects/#{project.id}/merge_requests/"\
                    "#{merge_request.id}/notes/#{merge_request_note.id}", user)
 
@@ -293,7 +293,7 @@ describe API::API, api: true  do
         expect(response.status).to eq(404)
       end
 
-      it 'should return a 404 error when note id not found' do
+      it 'returns a 404 error when note id not found' do
         delete api("/projects/#{project.id}/merge_requests/"\
                    "#{merge_request.id}/notes/123", user)
 
diff --git a/spec/services/notes/delete_service_spec.rb b/spec/services/notes/delete_service_spec.rb
index 07aa57c4642..1d0a747a480 100644
--- a/spec/services/notes/delete_service_spec.rb
+++ b/spec/services/notes/delete_service_spec.rb
@@ -1,13 +1,12 @@
 require 'spec_helper'
 
 describe Notes::DeleteService, services: true do
-  let(:project) { create(:empty_project) }
-  let(:issue) { create(:issue, project: project) }
-  let(:note) { create(:note, project: project, noteable: issue) }
-
   describe '#execute' do
     it 'deletes a note' do
-      project = note.project
+      project = create(:empty_project)
+      issue = create(:issue, project: project)
+      note = create(:note, project: project, noteable: issue)
+
       described_class.new(project, note.author).execute(note)
 
       expect(project.issues.find(issue.id).notes).not_to include(note)
-- 
GitLab