percentiles_spec.rb 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe AnnualReport::Percentiles do
  4. describe '#generate' do
  5. subject { described_class.new(account, year) }
  6. let(:year) { Time.zone.now.year }
  7. context 'with an inactive account' do
  8. let(:account) { Fabricate :account }
  9. it 'builds a report for an account' do
  10. described_class.prepare(year)
  11. expect(subject.generate)
  12. .to include(
  13. percentiles: include(
  14. statuses: 100
  15. )
  16. )
  17. end
  18. end
  19. context 'with an active account' do
  20. let(:account) { Fabricate :account }
  21. before do
  22. Fabricate.times 2, :status # Others as `account`
  23. Fabricate.times 2, :status, account: account
  24. end
  25. it 'builds a report for an account' do
  26. described_class.prepare(year)
  27. expect(subject.generate)
  28. .to include(
  29. percentiles: include(
  30. statuses: 50
  31. )
  32. )
  33. end
  34. end
  35. end
  36. end