Browse Source

CLDC-3821 Remove care home questions (#2885)

* Remove carehome questions for 2025

* Update routing to rent pages for 2025

* lint
pull/2893/head
kosiakkatrina 2 weeks ago committed by GitHub
parent
commit
5d7649a9e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 19
      app/models/form/lettings/pages/rent_4_weekly.rb
  2. 19
      app/models/form/lettings/pages/rent_bi_weekly.rb
  3. 19
      app/models/form/lettings/pages/rent_monthly.rb
  4. 19
      app/models/form/lettings/pages/rent_weekly.rb
  5. 22
      app/models/form/lettings/subsections/income_and_benefits.rb
  6. 44
      spec/models/form/lettings/pages/rent4_weekly_spec.rb
  7. 44
      spec/models/form/lettings/pages/rent_bi_weekly_spec.rb
  8. 44
      spec/models/form/lettings/pages/rent_monthly_spec.rb
  9. 44
      spec/models/form/lettings/pages/rent_weekly_spec.rb
  10. 93
      spec/models/form/lettings/subsections/income_and_benefits_spec.rb

19
app/models/form/lettings/pages/rent_4_weekly.rb

@ -3,10 +3,7 @@ class Form::Lettings::Pages::Rent4Weekly < ::Form::Page
super
@id = "rent_4_weekly"
@copy_key = "lettings.income_and_benefits.rent_and_charges"
@depends_on = [
{ "household_charge" => 0, "rent_and_charges_paid_every_4_weeks?" => true, "is_carehome?" => false },
{ "household_charge" => nil, "rent_and_charges_paid_every_4_weeks?" => true, "is_carehome?" => false },
]
@depends_on = depends_on
end
def questions
@ -18,4 +15,18 @@ class Form::Lettings::Pages::Rent4Weekly < ::Form::Page
Form::Lettings::Questions::Tcharge4Weekly.new(nil, nil, self),
]
end
def depends_on
if form.start_year_2025_or_later?
[
{ "household_charge" => 0, "rent_and_charges_paid_every_4_weeks?" => true },
{ "household_charge" => nil, "rent_and_charges_paid_every_4_weeks?" => true },
]
else
[
{ "household_charge" => 0, "rent_and_charges_paid_every_4_weeks?" => true, "is_carehome?" => false },
{ "household_charge" => nil, "rent_and_charges_paid_every_4_weeks?" => true, "is_carehome?" => false },
]
end
end
end

19
app/models/form/lettings/pages/rent_bi_weekly.rb

@ -3,10 +3,7 @@ class Form::Lettings::Pages::RentBiWeekly < ::Form::Page
super
@id = "rent_bi_weekly"
@copy_key = "lettings.income_and_benefits.rent_and_charges"
@depends_on = [
{ "household_charge" => nil, "rent_and_charges_paid_every_2_weeks?" => true, "is_carehome?" => false },
{ "household_charge" => 0, "rent_and_charges_paid_every_2_weeks?" => true, "is_carehome?" => false },
]
@depends_on = depends_on
end
def questions
@ -18,4 +15,18 @@ class Form::Lettings::Pages::RentBiWeekly < ::Form::Page
Form::Lettings::Questions::TchargeBiWeekly.new(nil, nil, self),
]
end
def depends_on
if form.start_year_2025_or_later?
[
{ "household_charge" => nil, "rent_and_charges_paid_every_2_weeks?" => true },
{ "household_charge" => 0, "rent_and_charges_paid_every_2_weeks?" => true },
]
else
[
{ "household_charge" => nil, "rent_and_charges_paid_every_2_weeks?" => true, "is_carehome?" => false },
{ "household_charge" => 0, "rent_and_charges_paid_every_2_weeks?" => true, "is_carehome?" => false },
]
end
end
end

19
app/models/form/lettings/pages/rent_monthly.rb

@ -3,10 +3,7 @@ class Form::Lettings::Pages::RentMonthly < ::Form::Page
super
@id = "rent_monthly"
@copy_key = "lettings.income_and_benefits.rent_and_charges"
@depends_on = [
{ "household_charge" => nil, "rent_and_charges_paid_monthly?" => true, "is_carehome?" => false },
{ "household_charge" => 0, "rent_and_charges_paid_monthly?" => true, "is_carehome?" => false },
]
@depends_on = depends_on
end
def questions
@ -18,4 +15,18 @@ class Form::Lettings::Pages::RentMonthly < ::Form::Page
Form::Lettings::Questions::TchargeMonthly.new(nil, nil, self),
]
end
def depends_on
if form.start_year_2025_or_later?
[
{ "household_charge" => nil, "rent_and_charges_paid_monthly?" => true },
{ "household_charge" => 0, "rent_and_charges_paid_monthly?" => true },
]
else
[
{ "household_charge" => nil, "rent_and_charges_paid_monthly?" => true, "is_carehome?" => false },
{ "household_charge" => 0, "rent_and_charges_paid_monthly?" => true, "is_carehome?" => false },
]
end
end
end

19
app/models/form/lettings/pages/rent_weekly.rb

@ -3,10 +3,7 @@ class Form::Lettings::Pages::RentWeekly < ::Form::Page
super
@id = "rent_weekly"
@copy_key = "lettings.income_and_benefits.rent_and_charges"
@depends_on = [
{ "rent_and_charges_paid_weekly?" => true, "household_charge" => 0, "is_carehome?" => false },
{ "rent_and_charges_paid_weekly?" => true, "household_charge" => nil, "is_carehome?" => false },
]
@depends_on = depends_on
end
def questions
@ -18,4 +15,18 @@ class Form::Lettings::Pages::RentWeekly < ::Form::Page
Form::Lettings::Questions::TchargeWeekly.new(nil, nil, self),
]
end
def depends_on
if form.start_year_2025_or_later?
[
{ "rent_and_charges_paid_weekly?" => true, "household_charge" => 0 },
{ "rent_and_charges_paid_weekly?" => true, "household_charge" => nil },
]
else
[
{ "rent_and_charges_paid_weekly?" => true, "household_charge" => 0, "is_carehome?" => false },
{ "rent_and_charges_paid_weekly?" => true, "household_charge" => nil, "is_carehome?" => false },
]
end
end
end

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

44
spec/models/form/lettings/pages/rent4_weekly_spec.rb

@ -0,0 +1,44 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::Rent4Weekly, type: :model do
subject(:page) { described_class.new(nil, page_definition, subsection) }
let(:page_definition) { nil }
let(:start_date) { Time.zone.local(2024, 4, 1) }
let(:start_year_2025_or_later) { false }
let(:form) { instance_double(Form, start_date:) }
let(:subsection) { instance_double(Form::Subsection, form:) }
let(:person_index) { 2 }
before do
allow(form).to receive(:start_year_2025_or_later?).and_return(start_year_2025_or_later)
end
context "with form before 2025" do
let(:start_date) { Time.zone.local(2024, 4, 1) }
let(:start_year_2025_or_later) { false }
it "has correct depends_on" do
expect(page.depends_on).to eq(
[
{ "rent_and_charges_paid_every_4_weeks?" => true, "household_charge" => 0, "is_carehome?" => false },
{ "rent_and_charges_paid_every_4_weeks?" => true, "household_charge" => nil, "is_carehome?" => false },
],
)
end
end
context "with form on or after 2025" do
let(:start_date) { Time.zone.local(2025, 4, 1) }
let(:start_year_2025_or_later) { true }
it "has correct depends_on" do
expect(page.depends_on).to eq(
[
{ "rent_and_charges_paid_every_4_weeks?" => true, "household_charge" => 0 },
{ "rent_and_charges_paid_every_4_weeks?" => true, "household_charge" => nil },
],
)
end
end
end

44
spec/models/form/lettings/pages/rent_bi_weekly_spec.rb

@ -0,0 +1,44 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::RentBiWeekly, type: :model do
subject(:page) { described_class.new(nil, page_definition, subsection) }
let(:page_definition) { nil }
let(:start_date) { Time.zone.local(2024, 4, 1) }
let(:start_year_2025_or_later) { false }
let(:form) { instance_double(Form, start_date:) }
let(:subsection) { instance_double(Form::Subsection, form:) }
let(:person_index) { 2 }
before do
allow(form).to receive(:start_year_2025_or_later?).and_return(start_year_2025_or_later)
end
context "with form before 2025" do
let(:start_date) { Time.zone.local(2024, 4, 1) }
let(:start_year_2025_or_later) { false }
it "has correct depends_on" do
expect(page.depends_on).to eq(
[
{ "rent_and_charges_paid_every_2_weeks?" => true, "household_charge" => nil, "is_carehome?" => false },
{ "rent_and_charges_paid_every_2_weeks?" => true, "household_charge" => 0, "is_carehome?" => false },
],
)
end
end
context "with form on or after 2025" do
let(:start_date) { Time.zone.local(2025, 4, 1) }
let(:start_year_2025_or_later) { true }
it "has correct depends_on" do
expect(page.depends_on).to eq(
[
{ "rent_and_charges_paid_every_2_weeks?" => true, "household_charge" => nil },
{ "rent_and_charges_paid_every_2_weeks?" => true, "household_charge" => 0 },
],
)
end
end
end

44
spec/models/form/lettings/pages/rent_monthly_spec.rb

@ -0,0 +1,44 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::RentMonthly, type: :model do
subject(:page) { described_class.new(nil, page_definition, subsection) }
let(:page_definition) { nil }
let(:start_date) { Time.zone.local(2024, 4, 1) }
let(:start_year_2025_or_later) { false }
let(:form) { instance_double(Form, start_date:) }
let(:subsection) { instance_double(Form::Subsection, form:) }
let(:person_index) { 2 }
before do
allow(form).to receive(:start_year_2025_or_later?).and_return(start_year_2025_or_later)
end
context "with form before 2025" do
let(:start_date) { Time.zone.local(2024, 4, 1) }
let(:start_year_2025_or_later) { false }
it "has correct depends_on" do
expect(page.depends_on).to eq(
[
{ "rent_and_charges_paid_monthly?" => true, "household_charge" => nil, "is_carehome?" => false },
{ "rent_and_charges_paid_monthly?" => true, "household_charge" => 0, "is_carehome?" => false },
],
)
end
end
context "with form on or after 2025" do
let(:start_date) { Time.zone.local(2025, 4, 1) }
let(:start_year_2025_or_later) { true }
it "has correct depends_on" do
expect(page.depends_on).to eq(
[
{ "rent_and_charges_paid_monthly?" => true, "household_charge" => nil },
{ "rent_and_charges_paid_monthly?" => true, "household_charge" => 0 },
],
)
end
end
end

44
spec/models/form/lettings/pages/rent_weekly_spec.rb

@ -0,0 +1,44 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::RentWeekly, type: :model do
subject(:page) { described_class.new(nil, page_definition, subsection) }
let(:page_definition) { nil }
let(:start_date) { Time.zone.local(2024, 4, 1) }
let(:start_year_2025_or_later) { false }
let(:form) { instance_double(Form, start_date:) }
let(:subsection) { instance_double(Form::Subsection, form:) }
let(:person_index) { 2 }
before do
allow(form).to receive(:start_year_2025_or_later?).and_return(start_year_2025_or_later)
end
context "with form before 2025" do
let(:start_date) { Time.zone.local(2024, 4, 1) }
let(:start_year_2025_or_later) { false }
it "has correct depends_on" do
expect(page.depends_on).to eq(
[
{ "rent_and_charges_paid_weekly?" => true, "household_charge" => 0, "is_carehome?" => false },
{ "rent_and_charges_paid_weekly?" => true, "household_charge" => nil, "is_carehome?" => false },
],
)
end
end
context "with form on or after 2025" do
let(:start_date) { Time.zone.local(2025, 4, 1) }
let(:start_year_2025_or_later) { true }
it "has correct depends_on" do
expect(page.depends_on).to eq(
[
{ "rent_and_charges_paid_weekly?" => true, "household_charge" => 0 },
{ "rent_and_charges_paid_weekly?" => true, "household_charge" => nil },
],
)
end
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