Add tests

This commit is contained in:
Claire 2023-11-17 14:08:00 +01:00
parent 379c226d70
commit e87f40a8b5
2 changed files with 32 additions and 0 deletions

View file

@ -8,6 +8,22 @@ describe '/api/v1/accounts' do
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
describe 'GET /api/v1/accounts?ids[]=:id' do
let(:account) { Fabricate(:account) }
let(:other_account) { Fabricate(:account) }
let(:scopes) { 'read:accounts' }
it 'returns expected response' do
get '/api/v1/accounts', headers: headers, params: { ids: [account.id, other_account.id, 123_123] }
expect(response).to have_http_status(200)
expect(body_as_json.with_indifferent_access).to include(
account.id.to_s.to_s => include(id: account.id.to_s),
other_account.id.to_s => include(id: other_account.id.to_s)
)
end
end
describe 'GET /api/v1/accounts/:id' do
context 'when logged out' do
let(:account) { Fabricate(:account) }

View file

@ -9,6 +9,22 @@ describe '/api/v1/statuses' do
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, application: client_app, scopes: scopes) }
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
describe 'GET /api/v1/statuses?ids[]=:id' do
let(:status) { Fabricate(:status) }
let(:other_status) { Fabricate(:status) }
let(:scopes) { 'read:statuses' }
it 'returns expected response' do
get '/api/v1/statuses', headers: headers, params: { ids: [status.id, other_status.id, 123_123] }
expect(response).to have_http_status(200)
expect(body_as_json.with_indifferent_access).to include(
status.id.to_s => include(id: status.id.to_s),
other_status.id.to_s => include(id: other_status.id.to_s)
)
end
end
describe 'GET /api/v1/statuses/:id' do
subject do
get "/api/v1/statuses/#{status.id}", headers: headers