diff --git a/app/models/form/lettings/subsections/household_characteristics.rb b/app/models/form/lettings/subsections/household_characteristics.rb index 104d72a0b..3cc8a201d 100644 --- a/app/models/form/lettings/subsections/household_characteristics.rb +++ b/app/models/form/lettings/subsections/household_characteristics.rb @@ -8,7 +8,6 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection def pages @pages ||= [ - (Form::Lettings::Pages::Declaration.new(nil, nil, self) unless form.start_year_2024_or_later?), Form::Lettings::Pages::HouseholdMembers.new(nil, nil, self), (Form::Lettings::Pages::NoFemalesPregnantHouseholdLeadHhmembValueCheck.new(nil, nil, self) unless form.start_year_2026_or_later?), (Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdLeadHhmembValueCheck.new(nil, nil, self) unless form.start_year_2026_or_later?), diff --git a/app/models/form/lettings/subsections/tenancy_information.rb b/app/models/form/lettings/subsections/tenancy_information.rb index e6ff48457..20dd3cd2d 100644 --- a/app/models/form/lettings/subsections/tenancy_information.rb +++ b/app/models/form/lettings/subsections/tenancy_information.rb @@ -16,7 +16,7 @@ class Form::Lettings::Subsections::TenancyInformation < ::Form::Subsection Form::Lettings::Pages::TenancyLength.new(nil, nil, self), Form::Lettings::Pages::TenancyLengthAffordableRent.new(nil, nil, self), Form::Lettings::Pages::TenancyLengthIntermediateRent.new(nil, nil, self), - (Form::Lettings::Pages::TenancyLengthPeriodic.new(nil, nil, self) if form.start_year_2024_or_later?), + Form::Lettings::Pages::TenancyLengthPeriodic.new(nil, nil, self), (Form::Lettings::Pages::ShelteredAccommodation.new(nil, nil, self) unless form.start_year_2025_or_later?), ].flatten.compact end diff --git a/app/models/form/sales/subsections/outright_sale.rb b/app/models/form/sales/subsections/outright_sale.rb index 0a7b2bbea..a2c21b7af 100644 --- a/app/models/form/sales/subsections/outright_sale.rb +++ b/app/models/form/sales/subsections/outright_sale.rb @@ -17,8 +17,6 @@ class Form::Sales::Subsections::OutrightSale < ::Form::Subsection Form::Sales::Pages::MortgageValueCheck.new("outright_sale_mortgage_used_mortgage_value_check", nil, self), Form::Sales::Pages::MortgageAmount.new("mortgage_amount_outright_sale", nil, self, ownershipsch: 3), Form::Sales::Pages::MortgageValueCheck.new("outright_sale_mortgage_amount_mortgage_value_check", nil, self), - (Form::Sales::Pages::MortgageLender.new("mortgage_lender_outright_sale", nil, self, ownershipsch: 3) unless form.start_year_2024_or_later?), - (Form::Sales::Pages::MortgageLenderOther.new("mortgage_lender_other_outright_sale", nil, self, ownershipsch: 3) unless form.start_year_2024_or_later?), Form::Sales::Pages::MortgageLength.new("mortgage_length_outright_sale", nil, self, ownershipsch: 3), Form::Sales::Pages::ExtraBorrowing.new("extra_borrowing_outright_sale", nil, self, ownershipsch: 3), Form::Sales::Pages::Deposit.new("deposit_outright_sale", nil, self, ownershipsch: 3, optional: false), diff --git a/app/models/form/sales/subsections/shared_ownership_scheme.rb b/app/models/form/sales/subsections/shared_ownership_scheme.rb index 5939e4d47..89a99ff89 100644 --- a/app/models/form/sales/subsections/shared_ownership_scheme.rb +++ b/app/models/form/sales/subsections/shared_ownership_scheme.rb @@ -37,15 +37,15 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection Form::Sales::Pages::MortgageLength.new("mortgage_length_shared_ownership", nil, self, ownershipsch: 1), Form::Sales::Pages::ExtraBorrowing.new("extra_borrowing_shared_ownership", nil, self, ownershipsch: 1), Form::Sales::Pages::Deposit.new("deposit_shared_ownership", nil, self, ownershipsch: 1, optional: false), - (Form::Sales::Pages::Deposit.new("deposit_shared_ownership_optional", nil, self, ownershipsch: 1, optional: true) if form.start_year_2024_or_later?), + Form::Sales::Pages::Deposit.new("deposit_shared_ownership_optional", nil, self, ownershipsch: 1, optional: true), Form::Sales::Pages::DepositValueCheck.new("deposit_joint_purchase_value_check", nil, self, joint_purchase: true), Form::Sales::Pages::DepositValueCheck.new("deposit_value_check", nil, self, joint_purchase: false), Form::Sales::Pages::DepositDiscount.new("deposit_discount", nil, self, optional: false), - (Form::Sales::Pages::DepositDiscount.new("deposit_discount_optional", nil, self, optional: true) if form.start_year_2024_or_later?), + Form::Sales::Pages::DepositDiscount.new("deposit_discount_optional", nil, self, optional: true), Form::Sales::Pages::MonthlyRent.new(nil, nil, self), Form::Sales::Pages::LeaseholdCharges.new("leasehold_charges_shared_ownership", nil, self, ownershipsch: 1), Form::Sales::Pages::MonthlyChargesValueCheck.new("monthly_charges_shared_ownership_value_check", nil, self), - ].compact + ] end def displayed_in_tasklist?(log) diff --git a/spec/models/form/lettings/subsections/tenancy_information_spec.rb b/spec/models/form/lettings/subsections/tenancy_information_spec.rb index 74d1dad19..2d3858a6f 100644 --- a/spec/models/form/lettings/subsections/tenancy_information_spec.rb +++ b/spec/models/form/lettings/subsections/tenancy_information_spec.rb @@ -16,30 +16,12 @@ RSpec.describe Form::Lettings::Subsections::TenancyInformation, type: :model do let(:form) { instance_double(Form, start_date:) } before do - allow(form).to receive_messages(start_year_2024_or_later?: true, start_year_2025_or_later?: false, start_year_2026_or_later?: false) - end - - context "when 2023" do - let(:start_date) { Time.utc(2023, 2, 8) } - - before do - allow(form).to receive_messages(start_year_2024_or_later?: false, start_year_2025_or_later?: false, start_year_2026_or_later?: false) - end - - it "has correct pages" do - expect(tenancy_information.pages.map(&:id)).to eq( - %w[joint starter_tenancy tenancy_type starter_tenancy_type tenancy_length tenancy_length_affordable_rent tenancy_length_intermediate_rent sheltered_accommodation], - ) - end + allow(form).to receive_messages(start_year_2025_or_later?: false, start_year_2026_or_later?: false) end context "when 2024" do let(:start_date) { Time.utc(2024, 2, 8) } - before do - allow(form).to receive_messages(start_year_2024_or_later?: true, start_year_2025_or_later?: false, start_year_2026_or_later?: false) - end - it "has correct pages" do expect(tenancy_information.pages.map(&:id)).to eq( %w[joint starter_tenancy tenancy_type starter_tenancy_type tenancy_length tenancy_length_affordable_rent tenancy_length_intermediate_rent tenancy_length_periodic sheltered_accommodation], @@ -51,7 +33,7 @@ RSpec.describe Form::Lettings::Subsections::TenancyInformation, type: :model do let(:start_date) { Time.utc(2025, 2, 8) } before do - allow(form).to receive_messages(start_year_2024_or_later?: true, start_year_2025_or_later?: true, start_year_2026_or_later?: false) + allow(form).to receive_messages(start_year_2025_or_later?: true, start_year_2026_or_later?: false) end it "has correct pages" do @@ -65,7 +47,7 @@ RSpec.describe Form::Lettings::Subsections::TenancyInformation, type: :model do let(:start_date) { Time.utc(2026, 2, 8) } before do - allow(form).to receive_messages(start_year_2024_or_later?: true, start_year_2025_or_later?: true, start_year_2026_or_later?: true) + allow(form).to receive_messages(start_year_2025_or_later?: true, start_year_2026_or_later?: true) end it "has correct pages" do diff --git a/spec/models/form/sales/subsections/outright_sale_spec.rb b/spec/models/form/sales/subsections/outright_sale_spec.rb index d7a79a01e..54a330f47 100644 --- a/spec/models/form/sales/subsections/outright_sale_spec.rb +++ b/spec/models/form/sales/subsections/outright_sale_spec.rb @@ -19,85 +19,28 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do describe "pages" do let(:section) { instance_double(described_class, form: instance_double(Form)) } - context "when 2022" do - before do - allow(form).to receive_messages(start_date: Time.zone.local(2022, 2, 8), start_year_2024_or_later?: false) - end - - it "has correct pages" do - expect(outright_sale.pages.compact.map(&:id)).to eq( - %w[ - purchase_price_outright_sale - about_price_outright_sale_value_check - mortgage_used_outright_sale - outright_sale_mortgage_used_mortgage_value_check - mortgage_amount_outright_sale - outright_sale_mortgage_amount_mortgage_value_check - mortgage_lender_outright_sale - mortgage_lender_other_outright_sale - mortgage_length_outright_sale - extra_borrowing_outright_sale - deposit_outright_sale - outright_sale_deposit_joint_purchase_value_check - outright_sale_deposit_value_check - monthly_charges_outright_sale_value_check - ], - ) - end + before do + allow(form).to receive_messages(start_date: Time.zone.local(2024, 2, 8)) end - context "when 2023" do - before do - allow(form).to receive_messages(start_date: Time.zone.local(2023, 2, 8), start_year_2024_or_later?: false) - end - - it "has correct pages" do - expect(outright_sale.pages.map(&:id)).to eq( - %w[ - purchase_price_outright_sale - about_price_outright_sale_value_check - mortgage_used_outright_sale - outright_sale_mortgage_used_mortgage_value_check - mortgage_amount_outright_sale - outright_sale_mortgage_amount_mortgage_value_check - mortgage_lender_outright_sale - mortgage_lender_other_outright_sale - mortgage_length_outright_sale - extra_borrowing_outright_sale - deposit_outright_sale - outright_sale_deposit_joint_purchase_value_check - outright_sale_deposit_value_check - leasehold_charges_outright_sale - monthly_charges_outright_sale_value_check - ], - ) - end - end - - context "when 2024" do - before do - allow(form).to receive_messages(start_date: Time.zone.local(2024, 2, 8), start_year_2024_or_later?: true) - end - - it "has correct pages" do - expect(outright_sale.pages.map(&:id)).to eq( - %w[ - purchase_price_outright_sale - about_price_outright_sale_value_check - mortgage_used_outright_sale - outright_sale_mortgage_used_mortgage_value_check - mortgage_amount_outright_sale - outright_sale_mortgage_amount_mortgage_value_check - mortgage_length_outright_sale - extra_borrowing_outright_sale - deposit_outright_sale - outright_sale_deposit_joint_purchase_value_check - outright_sale_deposit_value_check - leasehold_charges_outright_sale - monthly_charges_outright_sale_value_check - ], - ) - end + it "has correct pages" do + expect(outright_sale.pages.map(&:id)).to eq( + %w[ + purchase_price_outright_sale + about_price_outright_sale_value_check + mortgage_used_outright_sale + outright_sale_mortgage_used_mortgage_value_check + mortgage_amount_outright_sale + outright_sale_mortgage_amount_mortgage_value_check + mortgage_length_outright_sale + extra_borrowing_outright_sale + deposit_outright_sale + outright_sale_deposit_joint_purchase_value_check + outright_sale_deposit_value_check + leasehold_charges_outright_sale + monthly_charges_outright_sale_value_check + ], + ) end end diff --git a/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb b/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb index da2eb8303..111257a40 100644 --- a/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb +++ b/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb @@ -8,7 +8,7 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipScheme, type: :model do let(:section) { instance_double(Form::Sales::Sections::SaleInformation) } before do - allow(section).to receive(:form).and_return(instance_double(Form, start_year_2024_or_later?: false, start_year_2025_or_later?: false, start_date: Time.zone.local(2023, 4, 1))) + allow(section).to receive(:form).and_return(instance_double(Form, start_date: Time.zone.local(2024, 4, 1))) end it "has correct section" do @@ -46,9 +46,11 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipScheme, type: :model do mortgage_length_shared_ownership extra_borrowing_shared_ownership deposit_shared_ownership + deposit_shared_ownership_optional deposit_joint_purchase_value_check deposit_value_check deposit_discount + deposit_discount_optional monthly_rent leasehold_charges_shared_ownership monthly_charges_shared_ownership_value_check