0
0
Fork 0

Add option to request partial accounts in grouped notifications API (#31299)

This commit is contained in:
Claire 2024-08-06 14:09:35 +02:00 committed by GitHub
parent 5d890ebc57
commit 438dac99d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 88 additions and 9 deletions

View file

@ -160,6 +160,36 @@ RSpec.describe 'Notifications' do
end
end
context 'when requesting stripped-down accounts' do
let(:params) { { expand_accounts: 'partial_avatars' } }
let(:recent_account) { Fabricate(:account) }
before do
FavouriteService.new.call(recent_account, user.account.statuses.first)
end
it 'returns an account in "partial_accounts", with the expected keys', :aggregate_failures do
subject
expect(response).to have_http_status(200)
expect(body_as_json[:partial_accounts].size).to be > 0
expect(body_as_json[:partial_accounts][0].keys).to contain_exactly(:acct, :avatar, :avatar_static, :bot, :id, :locked, :url)
expect(body_as_json[:partial_accounts].pluck(:id)).to_not include(recent_account.id.to_s)
expect(body_as_json[:accounts].pluck(:id)).to include(recent_account.id.to_s)
end
end
context 'when passing an invalid value for "expand_accounts"' do
let(:params) { { expand_accounts: 'unknown_foobar' } }
it 'returns http bad request' do
subject
expect(response).to have_http_status(400)
end
end
def body_json_types
body_as_json[:notification_groups].pluck(:type)
end