0
0
Fork 0

Reduce extra round trips in activitypub controller specs (#31041)

This commit is contained in:
Matt Jankowski 2024-07-17 04:09:34 -04:00 committed by GitHub
parent f5e90f3de3
commit 76c2c5c748
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 56 additions and 126 deletions

View file

@ -25,14 +25,12 @@ RSpec.describe ActivityPub::CollectionsController do
context 'without signature' do
let(:remote_account) { nil }
it 'returns http success and correct media type' do
expect(response).to have_http_status(200)
expect(response.media_type).to eq 'application/activity+json'
end
it_behaves_like 'cacheable response'
it 'returns orderedItems with correct items' do
it 'returns http success and correct media type and correct items' do
expect(response).to have_http_status(200)
expect(response.media_type).to eq 'application/activity+json'
expect(body_as_json[:orderedItems])
.to be_an(Array)
.and have_attributes(size: 3)
@ -66,14 +64,12 @@ RSpec.describe ActivityPub::CollectionsController do
let(:remote_account) { Fabricate(:account, domain: 'example.com') }
context 'when getting a featured resource' do
it 'returns http success and correct media type' do
expect(response).to have_http_status(200)
expect(response.media_type).to eq 'application/activity+json'
end
it_behaves_like 'cacheable response'
it 'returns orderedItems with expected items' do
it 'returns http success and correct media type and expected items' do
expect(response).to have_http_status(200)
expect(response.media_type).to eq 'application/activity+json'
expect(body_as_json[:orderedItems])
.to be_an(Array)
.and have_attributes(size: 3)
@ -92,16 +88,14 @@ RSpec.describe ActivityPub::CollectionsController do
account.block!(remote_account)
end
it 'returns http success and correct media type and cache headers' do
it 'returns http success and correct media type and cache headers and empty items' do
expect(response).to have_http_status(200)
expect(response.media_type).to eq 'application/activity+json'
expect(response.headers['Cache-Control']).to include 'private'
end
it 'returns empty orderedItems' do
expect(body_as_json[:orderedItems])
.to be_an(Array)
.and have_attributes(size: 0)
.and be_empty
end
end
@ -110,16 +104,14 @@ RSpec.describe ActivityPub::CollectionsController do
account.block_domain!(remote_account.domain)
end
it 'returns http success and correct media type and cache headers' do
it 'returns http success and correct media type and cache headers and empty items' do
expect(response).to have_http_status(200)
expect(response.media_type).to eq 'application/activity+json'
expect(response.headers['Cache-Control']).to include 'private'
end
it 'returns empty orderedItems' do
expect(body_as_json[:orderedItems])
.to be_an(Array)
.and have_attributes(size: 0)
.and be_empty
end
end
end