Merge commit '607449336da198ea9fe9c014220a5374a0ca1ae4' into glitch-soc/merge-upstream

This commit is contained in:
Claire committed 2025-12-08 16:33:27 +01:00
commit 05e45beb34
48 files changed
+616 -219

No files matched your search

@@ -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