diff --git a/spec/factories/statements.rb b/spec/factories/statements.rb index 187d90ae20..6674235103 100644 --- a/spec/factories/statements.rb +++ b/spec/factories/statements.rb @@ -11,9 +11,9 @@ end month { Faker::Number.between(from: 1, to: 12) } - year { Faker::Number.between(from: 2021, to: 2024) } - deadline_date { Faker::Date.forward(days: 30) } - payment_date { Faker::Date.forward(days: 30) } + year { Faker::Number.between(from: 2022, to: 2024) } + deadline_date { Date.new(year, month, 1) - 6.days } + payment_date { Date.new(year, month, 25) } cohort { create(:cohort, :current) } lead_provider { declaration&.lead_provider || build(:lead_provider) } reconcile_amount { Faker::Number.decimal(l_digits: 3, r_digits: 2) } @@ -22,7 +22,7 @@ output_fee { true } trait(:next_output_fee) do - deadline_date { 1.day.from_now } + next_period output_fee { true } end diff --git a/spec/services/declarations/create_spec.rb b/spec/services/declarations/create_spec.rb index bef009e8da..4063a1f3ef 100644 --- a/spec/services/declarations/create_spec.rb +++ b/spec/services/declarations/create_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Declarations::Create, type: :model do let(:lead_provider) { LeadProvider.all.sample } - let(:cohort) { create(:cohort, :current) } + let(:cohort) { create(:cohort, start_year: 2022) } let(:course_group) { CourseGroup.find_by(name: "leadership") || create(:course_group, name: "leadership") } let(:course) { create(:course, :senior_leadership, course_group:) } let!(:schedule) { create(:schedule, :npq_leadership_autumn, course_group:, cohort:) } @@ -120,9 +120,13 @@ end context "with an fundable participant" do - let(:application) { create(:application, :eligible_for_funded_place, cohort:, course:, lead_provider:) } let(:existing_declaration) { Declaration.last } + before do + cohort.update! funding_cap: true + application.update! eligible_for_funding: true + end + %w[eligible payable paid].each do |state| context "when the state is #{state}" do before { existing_declaration.update!(state:) } @@ -248,7 +252,7 @@ end context "when there are no available output fee statements" do - before { lead_provider.next_output_fee_statement(cohort).update!(output_fee: false) } + before { lead_provider.next_output_fee_statement(cohort).try(:update!, { output_fee: false }) } context "when the declarations is submitted" do it { is_expected.to be_valid } @@ -299,7 +303,9 @@ it "calls `StatementAttacher`" do expect_any_instance_of(Declarations::StatementAttacher).to receive(:attach) - subject + travel_to statement.deadline_date - 1.day do + subject + end end end