Use group/count approach in annual report classes (#32914)

This commit is contained in:
Matt Jankowski 2024-11-19 03:51:34 -05:00 committed by GitHub
parent 295ad6f19a
commit 425982841d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 52 additions and 13 deletions

View file

@ -21,18 +21,26 @@ RSpec.describe AnnualReport::MostRebloggedAccounts do
let(:account) { Fabricate :account }
let(:other_account) { Fabricate :account }
let(:most_other_account) { Fabricate :account }
before do
_other = Fabricate :status
Fabricate :status, account: account, reblog: Fabricate(:status, account: other_account)
Fabricate :status, account: account, reblog: Fabricate(:status, account: other_account)
Fabricate :status, account: account, reblog: Fabricate(:status, account: most_other_account)
Fabricate :status, account: account, reblog: Fabricate(:status, account: most_other_account)
Fabricate :status, account: account, reblog: Fabricate(:status, account: most_other_account)
end
it 'builds a report for an account' do
expect(subject.generate)
.to include(
most_reblogged_accounts: contain_exactly(
include(account_id: other_account.id.to_s, count: 2)
most_reblogged_accounts: eq(
[
{ account_id: most_other_account.id.to_s, count: 3 },
{ account_id: other_account.id.to_s, count: 2 },
]
)
)
end