You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.3 KiB
41 lines
1.3 KiB
2 years ago
|
# frozen_string_literal: true
|
||
|
|
||
3 years ago
|
require 'rails_helper'
|
||
|
|
||
11 months ago
|
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}" } }
|
||
3 years ago
|
let(:account) { Fabricate(:account) }
|
||
|
let(:comment) { 'foo' }
|
||
|
|
||
11 months ago
|
describe 'POST /api/v1/accounts/:account_id/note' do
|
||
3 years ago
|
subject do
|
||
11 months ago
|
post "/api/v1/accounts/#{account.id}/note", params: { comment: comment }, headers: headers
|
||
3 years ago
|
end
|
||
|
|
||
1 year ago
|
context 'when account note has reasonable length', :aggregate_failures do
|
||
3 years ago
|
let(:comment) { 'foo' }
|
||
|
|
||
|
it 'updates account note' do
|
||
|
subject
|
||
1 year ago
|
|
||
|
expect(response).to have_http_status(200)
|
||
3 years ago
|
expect(AccountNote.find_by(account_id: user.account.id, target_account_id: account.id).comment).to eq comment
|
||
|
end
|
||
|
end
|
||
|
|
||
1 year ago
|
context 'when account note exceeds allowed length', :aggregate_failures do
|
||
3 years ago
|
let(:comment) { 'a' * 2_001 }
|
||
|
|
||
|
it 'does not create account note' do
|
||
|
subject
|
||
1 year ago
|
|
||
|
expect(response).to have_http_status(422)
|
||
2 years ago
|
expect(AccountNote.where(account_id: user.account.id, target_account_id: account.id)).to_not exist
|
||
3 years ago
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|