top_statuses_spec.rb 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe AnnualReport::TopStatuses 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. top_statuses: include(
  12. by_reblogs: be_nil,
  13. by_favourites: be_nil,
  14. by_replies: be_nil
  15. )
  16. )
  17. end
  18. end
  19. context 'with an active account' do
  20. let(:account) { Fabricate :account }
  21. let(:reblogged_status) { Fabricate :status, account: account }
  22. let(:favourited_status) { Fabricate :status, account: account }
  23. let(:replied_status) { Fabricate :status, account: account }
  24. before do
  25. _other = Fabricate :status
  26. reblogged_status.status_stat.update(reblogs_count: 123)
  27. favourited_status.status_stat.update(favourites_count: 123)
  28. replied_status.status_stat.update(replies_count: 123)
  29. end
  30. it 'builds a report for an account' do
  31. expect(subject.generate)
  32. .to include(
  33. top_statuses: include(
  34. by_reblogs: reblogged_status.id.to_s,
  35. by_favourites: favourited_status.id.to_s,
  36. by_replies: replied_status.id.to_s
  37. )
  38. )
  39. end
  40. end
  41. end
  42. end