time_series_spec.rb 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe AnnualReport::TimeSeries 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. time_series: match(
  12. include(followers: 0, following: 0, month: 1, statuses: 0)
  13. )
  14. )
  15. end
  16. end
  17. context 'with an active account' do
  18. let(:account) { Fabricate :account }
  19. let(:month_one_date) { DateTime.new(Time.zone.now.year, 1, 1, 12, 12, 12) }
  20. let(:tag) { Fabricate :tag }
  21. before do
  22. _other = Fabricate :status
  23. Fabricate :status, account: account, created_at: month_one_date
  24. Fabricate :follow, account: account, created_at: month_one_date
  25. Fabricate :follow, target_account: account, created_at: month_one_date
  26. end
  27. it 'builds a report for an account' do
  28. expect(subject.generate)
  29. .to include(
  30. time_series: match(
  31. include(followers: 1, following: 1, month: 1, statuses: 1)
  32. )
  33. )
  34. end
  35. end
  36. end
  37. end