most_reblogged_accounts_spec.rb 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe AnnualReport::MostRebloggedAccounts do
  4. describe '#generate' do
  5. subject { described_class.new(account, Time.zone.now.year) }
  6. context 'with an inactive account' do
  7. let(:account) { Fabricate :account }
  8. it 'builds a report for an account' do
  9. expect(subject.generate)
  10. .to include(
  11. most_reblogged_accounts: be_an(Array).and(be_empty)
  12. )
  13. end
  14. end
  15. context 'with an active account' do
  16. let(:account) { Fabricate :account }
  17. let(:other_account) { Fabricate :account }
  18. let(:most_other_account) { Fabricate :account }
  19. before do
  20. _other = Fabricate :status
  21. Fabricate :status, account: account, reblog: Fabricate(:status, account: other_account)
  22. Fabricate :status, account: account, reblog: Fabricate(:status, account: other_account)
  23. Fabricate :status, account: account, reblog: Fabricate(:status, account: most_other_account)
  24. Fabricate :status, account: account, reblog: Fabricate(:status, account: most_other_account)
  25. Fabricate :status, account: account, reblog: Fabricate(:status, account: most_other_account)
  26. end
  27. it 'builds a report for an account' do
  28. expect(subject.generate)
  29. .to include(
  30. most_reblogged_accounts: eq(
  31. [
  32. { account_id: most_other_account.id.to_s, count: 3 },
  33. { account_id: other_account.id.to_s, count: 2 },
  34. ]
  35. )
  36. )
  37. end
  38. end
  39. end
  40. end