|
| 1 | +require 'rails_helper' |
| 2 | +require File.expand_path('shared_examples_for_reports.rb', __dir__) |
| 3 | + |
| 4 | +RSpec.describe Reports::ProvisionalAssessmentsSummary do |
| 5 | + subject(:report) { described_class.new } |
| 6 | + |
| 7 | + describe '::COLUMNS' do |
| 8 | + subject { described_class::COLUMNS } |
| 9 | + |
| 10 | + it { is_expected.to eq( |
| 11 | + %w[ |
| 12 | + supplier_name |
| 13 | + total |
| 14 | + assessed |
| 15 | + disallowed |
| 16 | + ] |
| 17 | + )} |
| 18 | + end |
| 19 | + |
| 20 | + it_behaves_like 'data for an MI report' |
| 21 | + |
| 22 | + describe '#call' do |
| 23 | + subject(:call) { described_class.call } |
| 24 | + |
| 25 | + context 'with a single draft claim' do |
| 26 | + before { create(:claim, :draft) } |
| 27 | + |
| 28 | + it { is_expected.to be_empty } |
| 29 | + end |
| 30 | + |
| 31 | + context 'with a single submitted claim' do |
| 32 | + before { create(:claim, :submitted) } |
| 33 | + |
| 34 | + it { is_expected.to be_empty } |
| 35 | + end |
| 36 | + |
| 37 | + context 'with a single allocated claim' do |
| 38 | + before { create(:claim, :allocated) } |
| 39 | + |
| 40 | + it { is_expected.to be_empty } |
| 41 | + end |
| 42 | + |
| 43 | + context 'with a single rejected claim' do |
| 44 | + before { create(:claim, :rejected) } |
| 45 | + |
| 46 | + it { is_expected.to be_empty } |
| 47 | + end |
| 48 | + |
| 49 | + context 'with a single redetermination claim' do |
| 50 | + before { create(:claim, :redetermination) } |
| 51 | + |
| 52 | + it { is_expected.to be_empty } |
| 53 | + end |
| 54 | + |
| 55 | + context 'with a single authorised claim' do |
| 56 | + before { create(:claim, :authorised) } |
| 57 | + |
| 58 | + it { expect(call.length).to eq(1) } |
| 59 | + end |
| 60 | + |
| 61 | + context 'with a single part_authorised claim' do |
| 62 | + let!(:claim) do |
| 63 | + create( |
| 64 | + :claim, :part_authorised, |
| 65 | + external_user: |
| 66 | + ) |
| 67 | + end |
| 68 | + let(:external_user) { build(:external_user, provider: build(:provider, name: 'Test provider')) } |
| 69 | + |
| 70 | + it { expect(call.length).to eq(1) } |
| 71 | + it { expect(call.first.length).to eq(4) } |
| 72 | + it { expect(call.first[0]).to eq('Test provider') } |
| 73 | + it { expect(call.first[1]).to eq(claim.total_including_vat) } |
| 74 | + it { expect(call.first[2]).to eq(claim.amount_assessed) } |
| 75 | + it { expect(call.first[3]).to eq(claim.total_including_vat - claim.amount_assessed) } |
| 76 | + end |
| 77 | + end |
| 78 | +end |
0 commit comments