2024-09-11 17:01:32 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe AnnualReport::Percentiles do
|
|
|
|
describe '#generate' do
|
2024-11-04 19:11:06 +09:00
|
|
|
subject { described_class.new(account, year) }
|
|
|
|
|
|
|
|
let(:year) { Time.zone.now.year }
|
2024-09-11 17:01:32 +09:00
|
|
|
|
|
|
|
context 'with an inactive account' do
|
|
|
|
let(:account) { Fabricate :account }
|
|
|
|
|
|
|
|
it 'builds a report for an account' do
|
2024-11-04 19:11:06 +09:00
|
|
|
described_class.prepare(year)
|
|
|
|
|
2024-09-11 17:01:32 +09:00
|
|
|
expect(subject.generate)
|
|
|
|
.to include(
|
|
|
|
percentiles: include(
|
2024-11-04 19:11:06 +09:00
|
|
|
statuses: 100
|
2024-09-11 17:01:32 +09:00
|
|
|
)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with an active account' do
|
|
|
|
let(:account) { Fabricate :account }
|
|
|
|
|
|
|
|
before do
|
|
|
|
Fabricate.times 2, :status # Others as `account`
|
|
|
|
Fabricate.times 2, :status, account: account
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'builds a report for an account' do
|
2024-11-04 19:11:06 +09:00
|
|
|
described_class.prepare(year)
|
|
|
|
|
2024-09-11 17:01:32 +09:00
|
|
|
expect(subject.generate)
|
|
|
|
.to include(
|
|
|
|
percentiles: include(
|
|
|
|
statuses: 50
|
|
|
|
)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|