From 94cc707ab398339dfe74472300056876fac81856 Mon Sep 17 00:00:00 2001
From: Matt Jankowski <matt@jankowski.online>
Date: Mon, 11 Dec 2023 02:58:48 -0500
Subject: [PATCH] Controller spec to request spec: `api/v1/accounts/notes`
 (#28301)

---
 .../api/v1/accounts/notes_spec.rb}             | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
 rename spec/{controllers/api/v1/accounts/notes_controller_spec.rb => requests/api/v1/accounts/notes_spec.rb} (66%)

diff --git a/spec/controllers/api/v1/accounts/notes_controller_spec.rb b/spec/requests/api/v1/accounts/notes_spec.rb
similarity index 66%
rename from spec/controllers/api/v1/accounts/notes_controller_spec.rb
rename to spec/requests/api/v1/accounts/notes_spec.rb
index 75599b32b2..4f3ac68c74 100644
--- a/spec/controllers/api/v1/accounts/notes_controller_spec.rb
+++ b/spec/requests/api/v1/accounts/notes_spec.rb
@@ -2,21 +2,17 @@
 
 require 'rails_helper'
 
-describe Api::V1::Accounts::NotesController do
-  render_views
-
-  let(:user)    { Fabricate(:user) }
-  let(:token)   { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'write:accounts') }
+describe 'Accounts Notes API' do
+  let(:user)     { Fabricate(:user) }
+  let(:token)    { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
+  let(:scopes)   { 'write:accounts' }
+  let(:headers)  { { 'Authorization' => "Bearer #{token.token}" } }
   let(:account) { Fabricate(:account) }
   let(:comment) { 'foo' }
 
-  before do
-    allow(controller).to receive(:doorkeeper_token) { token }
-  end
-
-  describe 'POST #create' do
+  describe 'POST /api/v1/accounts/:account_id/note' do
     subject do
-      post :create, params: { account_id: account.id, comment: comment }
+      post "/api/v1/accounts/#{account.id}/note", params: { comment: comment }, headers: headers
     end
 
     context 'when account note has reasonable length', :aggregate_failures do