Browse Source

feat: remove pages from 2024 and test (#2191)

pull/2195/head
natdeanlewissoftwire 11 months ago committed by GitHub
parent
commit
83492b10ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      app/models/form/sales/subsections/outright_sale.rb
  2. 44
      spec/models/form/sales/subsections/outright_sale_spec.rb

6
app/models/form/sales/subsections/outright_sale.rb

@ -14,15 +14,15 @@ 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),
Form::Sales::Pages::MortgageLenderOther.new("mortgage_lender_other_outright_sale", nil, self, ownershipsch: 3),
(Form::Sales::Pages::MortgageLender.new("mortgage_lender_outright_sale", nil, self, ownershipsch: 3) unless form.start_year_after_2024?),
(Form::Sales::Pages::MortgageLenderOther.new("mortgage_lender_other_outright_sale", nil, self, ownershipsch: 3) unless form.start_year_after_2024?),
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::AboutDepositWithoutDiscount.new("about_deposit_outright_sale", nil, self, ownershipsch: 3),
Form::Sales::Pages::DepositValueCheck.new("outright_sale_deposit_value_check", nil, self),
leasehold_charge_pages,
Form::Sales::Pages::MonthlyChargesValueCheck.new("monthly_charges_outright_sale_value_check", nil, self),
].compact
].flatten.compact
end
def displayed_in_tasklist?(log)

44
spec/models/form/sales/subsections/outright_sale_spec.rb

@ -6,16 +6,24 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do
let(:subsection_id) { nil }
let(:subsection_definition) { nil }
let(:section) { instance_double(Form::Sales::Sections::SaleInformation) }
let(:form) { instance_double(Form) }
before do
allow(section).to receive(:form).and_return(form)
end
it "has correct section" do
expect(outright_sale.section).to eq(section)
end
describe "pages" do
let(:section) { instance_double(described_class, form: instance_double(Form, start_date:)) }
let(:section) { instance_double(described_class, form: instance_double(Form)) }
context "when 2022" do
let(:start_date) { Time.utc(2022, 2, 8) }
before do
allow(form).to receive(:start_date).and_return(Time.zone.local(2022, 2, 8))
allow(form).to receive(:start_year_after_2024?).and_return(false)
end
it "has correct pages" do
expect(outright_sale.pages.compact.map(&:id)).to eq(
@ -39,7 +47,11 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do
end
context "when 2023" do
let(:start_date) { Time.utc(2023, 2, 8) }
before do
allow(form).to receive(:start_date).and_return(Time.zone.local(2023, 2, 8))
allow(form).to receive(:start_year_after_2024?).and_return(false)
end
it "has correct pages" do
expect(outright_sale.pages.map(&:id)).to eq(
@ -62,6 +74,32 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do
)
end
end
context "when 2024" do
before do
allow(form).to receive(:start_date).and_return(Time.zone.local(2024, 2, 8))
allow(form).to receive(:start_year_after_2024?).and_return(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
about_deposit_outright_sale
outright_sale_deposit_value_check
leasehold_charges_outright_sale
monthly_charges_outright_sale_value_check
],
)
end
end
end
it "has the correct id" do

Loading…
Cancel
Save