Browse Source

Remove carehome questions for 2025

pull/2885/head
Kat 5 months ago
parent
commit
321aa1eaf8
  1. 22
      app/models/form/lettings/subsections/income_and_benefits.rb
  2. 93
      spec/models/form/lettings/subsections/income_and_benefits_spec.rb

22
app/models/form/lettings/subsections/income_and_benefits.rb

@ -15,11 +15,7 @@ class Form::Lettings::Subsections::IncomeAndBenefits < ::Form::Subsection
Form::Lettings::Pages::BenefitsProportion.new("benefits_proportion", nil, self),
Form::Lettings::Pages::RentOrOtherCharges.new(nil, nil, self),
Form::Lettings::Pages::RentPeriod.new(nil, nil, self),
Form::Lettings::Pages::CareHomeWeekly.new(nil, nil, self),
Form::Lettings::Pages::CareHomeBiWeekly.new(nil, nil, self),
Form::Lettings::Pages::CareHome4Weekly.new(nil, nil, self),
Form::Lettings::Pages::CareHomeMonthly.new(nil, nil, self),
Form::Lettings::Pages::CareHomeChargesValueCheck.new(nil, nil, self),
carehome_questions,
Form::Lettings::Pages::RentWeekly.new(nil, nil, self),
Form::Lettings::Pages::RentBiWeekly.new(nil, nil, self),
Form::Lettings::Pages::Rent4Weekly.new(nil, nil, self),
@ -30,6 +26,20 @@ class Form::Lettings::Subsections::IncomeAndBenefits < ::Form::Subsection
Form::Lettings::Pages::SupchargValueCheck.new(nil, nil, self),
Form::Lettings::Pages::Outstanding.new(nil, nil, self),
Form::Lettings::Pages::OutstandingAmount.new(nil, nil, self),
].compact
].flatten.compact
end
private
def carehome_questions
return [] if form.start_year_2025_or_later?
[
Form::Lettings::Pages::CareHomeWeekly.new(nil, nil, self),
Form::Lettings::Pages::CareHomeBiWeekly.new(nil, nil, self),
Form::Lettings::Pages::CareHome4Weekly.new(nil, nil, self),
Form::Lettings::Pages::CareHomeMonthly.new(nil, nil, self),
Form::Lettings::Pages::CareHomeChargesValueCheck.new(nil, nil, self),
]
end
end

93
spec/models/form/lettings/subsections/income_and_benefits_spec.rb

@ -5,40 +5,77 @@ RSpec.describe Form::Lettings::Subsections::IncomeAndBenefits, type: :model do
let(:subsection_id) { nil }
let(:subsection_definition) { nil }
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
let(:start_date) { Time.zone.local(2024, 4, 1) }
let(:start_year_2025_or_later) { false }
let(:form) { instance_double(Form, start_date:) }
let(:section) { instance_double(Form::Lettings::Sections::RentAndCharges, form:) }
before do
allow(form).to receive(:start_year_2025_or_later?).and_return(start_year_2025_or_later)
end
it "has correct section" do
expect(income_and_benefits.section).to eq(section)
end
it "has correct pages" do
expect(income_and_benefits.pages.map(&:id)).to eq(
%w[
income_known
income_amount
net_income_value_check
housing_benefit
benefits_proportion
rent_or_other_charges
rent_period
care_home_weekly
care_home_bi_weekly
care_home_4_weekly
care_home_monthly
care_home_charges_value_check
rent_weekly
rent_bi_weekly
rent_4_weekly
rent_monthly
brent_rent_value_check
scharge_value_check
pscharge_value_check
supcharg_value_check
outstanding
outstanding_amount
],
)
context "with 2024 form" do
it "has correct pages" do
expect(income_and_benefits.pages.map(&:id)).to eq(
%w[
income_known
income_amount
net_income_value_check
housing_benefit
benefits_proportion
rent_or_other_charges
rent_period
care_home_weekly
care_home_bi_weekly
care_home_4_weekly
care_home_monthly
care_home_charges_value_check
rent_weekly
rent_bi_weekly
rent_4_weekly
rent_monthly
brent_rent_value_check
scharge_value_check
pscharge_value_check
supcharg_value_check
outstanding
outstanding_amount
],
)
end
end
context "with 2025 form" do
let(:start_date) { Time.zone.local(2025, 4, 1) }
let(:start_year_2025_or_later) { true }
it "has correct pages" do
expect(income_and_benefits.pages.map(&:id)).to eq(
%w[
income_known
income_amount
net_income_value_check
housing_benefit
benefits_proportion
rent_or_other_charges
rent_period
rent_weekly
rent_bi_weekly
rent_4_weekly
rent_monthly
brent_rent_value_check
scharge_value_check
pscharge_value_check
supcharg_value_check
outstanding
outstanding_amount
],
)
end
end
it "has the correct id" do

Loading…
Cancel
Save