Controller spec to request spec: `api/v1/accounts/notes` (#28301)

th-new
Matt Jankowski 2023-12-11 02:58:48 -05:00 committed by GitHub
parent e544b6df42
commit 94cc707ab3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 11 deletions

View File

@ -2,21 +2,17 @@
require 'rails_helper' require 'rails_helper'
describe Api::V1::Accounts::NotesController do describe 'Accounts Notes API' do
render_views let(:user) { Fabricate(:user) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
let(:user) { Fabricate(:user) } let(:scopes) { 'write:accounts' }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'write:accounts') } let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
let(:account) { Fabricate(:account) } let(:account) { Fabricate(:account) }
let(:comment) { 'foo' } let(:comment) { 'foo' }
before do describe 'POST /api/v1/accounts/:account_id/note' do
allow(controller).to receive(:doorkeeper_token) { token }
end
describe 'POST #create' do
subject 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 end
context 'when account note has reasonable length', :aggregate_failures do context 'when account note has reasonable length', :aggregate_failures do