Add coverage for AnnualReport::* source child classes (#31849)

This commit is contained in:
Matt Jankowski 2024-09-11 04:01:32 -04:00 committed by GitHub
parent 9769ffdcc2
commit cdcd834f3c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 353 additions and 0 deletions

View file

@ -0,0 +1,44 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe AnnualReport::Percentiles do
describe '#generate' do
subject { described_class.new(account, Time.zone.now.year) }
context 'with an inactive account' do
let(:account) { Fabricate :account }
it 'builds a report for an account' do
expect(subject.generate)
.to include(
percentiles: include(
followers: 0,
statuses: 0
)
)
end
end
context 'with an active account' do
let(:account) { Fabricate :account }
before do
Fabricate.times 2, :status # Others as `account`
Fabricate.times 2, :follow # Others as `target_account`
Fabricate.times 2, :status, account: account
Fabricate.times 2, :follow, target_account: account
end
it 'builds a report for an account' do
expect(subject.generate)
.to include(
percentiles: include(
followers: 50,
statuses: 50
)
)
end
end
end
end