mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-24 19:37:26 +00:00
Draft API to get all collections by an account (#37139)
This commit is contained in:
@@ -5,6 +5,58 @@ require 'rails_helper'
|
||||
RSpec.describe 'Api::V1Alpha::Collections', feature: :collections do
|
||||
include_context 'with API authentication', oauth_scopes: 'read:collections write:collections'
|
||||
|
||||
describe 'GET /api/v1_alpha/accounts/:account_id/collections' do
|
||||
subject do
|
||||
get "/api/v1_alpha/accounts/#{account.id}/collections", headers: headers, params: params
|
||||
end
|
||||
|
||||
let(:params) { {} }
|
||||
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
before { Fabricate.times(3, :collection, account:) }
|
||||
|
||||
it 'returns all collections for the given account and http success' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.parsed_body.size).to eq 3
|
||||
end
|
||||
|
||||
context 'with limit param' do
|
||||
let(:params) { { limit: '1' } }
|
||||
|
||||
it 'returns only a single result' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.parsed_body.size).to eq 1
|
||||
|
||||
expect(response)
|
||||
.to include_pagination_headers(
|
||||
next: api_v1_alpha_account_collections_url(account, limit: 1, offset: 1)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with limit and offset params' do
|
||||
let(:params) { { limit: '1', offset: '1' } }
|
||||
|
||||
it 'returns the correct result and headers' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.parsed_body.size).to eq 1
|
||||
|
||||
expect(response)
|
||||
.to include_pagination_headers(
|
||||
prev: api_v1_alpha_account_collections_url(account, limit: 1, offset: 0),
|
||||
next: api_v1_alpha_account_collections_url(account, limit: 1, offset: 2)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET /api/v1_alpha/collections/:id' do
|
||||
subject do
|
||||
get "/api/v1_alpha/collections/#{collection.id}", headers: headers
|
||||
|
||||
Reference in New Issue
Block a user