From 63655c1c71754a5957690a768b69fb6b9864ad57 Mon Sep 17 00:00:00 2001 From: Richard Worrall Date: Fri, 20 Dec 2024 13:12:01 +0000 Subject: [PATCH] [CPDNPQ-2419] Fix some flakey tests --- .../admin/finance/voided_declarations_spec.rb | 2 +- spec/models/lead_provider_spec.rb | 12 ++++++------ spec/services/statements/summary_calculator_spec.rb | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/spec/features/npq_separation/admin/finance/voided_declarations_spec.rb b/spec/features/npq_separation/admin/finance/voided_declarations_spec.rb index 1aba5c4f49..2a6b59fefc 100644 --- a/spec/features/npq_separation/admin/finance/voided_declarations_spec.rb +++ b/spec/features/npq_separation/admin/finance/voided_declarations_spec.rb @@ -20,7 +20,7 @@ expect(page).to have_css("td:nth-child(1)", text: voided_declaration.id) expect(page).to have_css("td:nth-child(2)", text: voided_declaration.user.id) expect(page).to have_css("td:nth-child(3)", text: voided_declaration.declaration_type) - expect(page).to have_css("td:nth-child(4)", text: voided_declaration.course.name) + expect(page).to have_css("td:nth-child(4)", text: voided_declaration.reload.course.name) expect(page).not_to have_css("td:nth-child(1)", text: eligible_declaration.id) expect(page).not_to have_css("td:nth-child(1)", text: other_voided_declaration.id) diff --git a/spec/models/lead_provider_spec.rb b/spec/models/lead_provider_spec.rb index b817a4a8b2..ac03040079 100644 --- a/spec/models/lead_provider_spec.rb +++ b/spec/models/lead_provider_spec.rb @@ -18,17 +18,17 @@ before do # Not output fee - create(:statement, output_fee: false, cohort:, lead_provider:, deadline_date: 1.hour.from_now) + create(:statement, :next_period, output_fee: false, cohort:, lead_provider:, deadline_date: 1.hour.from_now) # Paid - create(:statement, :paid, :next_output_fee, cohort:, lead_provider:, deadline_date: 2.hours.from_now) + create(:statement, :next_period, :paid, :next_output_fee, cohort:, lead_provider:, deadline_date: 2.hours.from_now) # Payable - create(:statement, :payable, :next_output_fee, cohort:, lead_provider:, deadline_date: 3.hours.from_now) + create(:statement, :next_period, :payable, :next_output_fee, cohort:, lead_provider:, deadline_date: 3.hours.from_now) # Deadline is later - create(:statement, output_fee: true, cohort:, lead_provider:, deadline_date: 2.days.from_now) + create(:statement, :next_period, output_fee: true, cohort:, lead_provider:, deadline_date: 2.days.from_now) # Wrong cohort - create(:statement, output_fee: true, cohort: create(:cohort, start_year: cohort.start_year + 1), lead_provider:, deadline_date: 1.hour.from_now) + create(:statement, :next_period, output_fee: true, cohort: create(:cohort, start_year: cohort.start_year + 1), lead_provider:, deadline_date: 1.hour.from_now) # In the past - create(:statement, output_fee: true, cohort:, lead_provider:, deadline_date: 1.day.ago) + create(:statement, :next_period, output_fee: true, cohort:, lead_provider:, deadline_date: 1.day.ago) end subject { lead_provider.next_output_fee_statement(cohort) } diff --git a/spec/services/statements/summary_calculator_spec.rb b/spec/services/statements/summary_calculator_spec.rb index 43dae47b6e..5d569bd0f4 100644 --- a/spec/services/statements/summary_calculator_spec.rb +++ b/spec/services/statements/summary_calculator_spec.rb @@ -109,7 +109,7 @@ create(:declaration, :paid, declaration_type:, lead_provider:, application:, cohort:, statement: paid_statement) end end - let!(:statement) { create(:statement, :next_output_fee, deadline_date: paid_statement.deadline_date + 1.month, lead_provider:) } + let!(:statement) { create(:statement, :next_period, :next_output_fee, deadline_date: paid_statement.deadline_date + 1.month, lead_provider:) } before do travel_to statement.deadline_date do @@ -153,7 +153,7 @@ create(:declaration, :paid, declaration_type: "retained-1", lead_provider:, application:, statement: paid_statement) end end - let!(:statement) { create(:statement, :next_output_fee, deadline_date: paid_statement.deadline_date + 1.month, lead_provider:) } + let!(:statement) { create(:statement, :next_period, :next_output_fee, deadline_date: paid_statement.deadline_date + 1.month, lead_provider:) } before do travel_to statement.deadline_date do @@ -274,7 +274,7 @@ end let!(:to_be_awaiting_clawed_back) do - travel_to create(:statement, :next_output_fee, deadline_date: statement.deadline_date - 1.month, lead_provider:).deadline_date do + travel_to create(:statement, :next_period, :next_output_fee, deadline_date: statement.deadline_date - 1.month, lead_provider:).deadline_date do create(:declaration, :paid, declaration_type:, application:, lead_provider:) end end @@ -307,7 +307,7 @@ end let!(:to_be_awaiting_clawed_back) do - travel_to create(:statement, :next_output_fee, deadline_date: statement.deadline_date - 1.month, lead_provider:).deadline_date do + travel_to create(:statement, :next_period, :next_output_fee, deadline_date: statement.deadline_date - 1.month, lead_provider:).deadline_date do create(:declaration, :paid, declaration_type:, application:, lead_provider:, statement:) end end