From 71a6a233c004b038399fdc96284f6eb84ecc0dfe Mon Sep 17 00:00:00 2001 From: Rachael Booth Date: Tue, 7 Jan 2025 16:36:51 +0000 Subject: [PATCH] CLDC-3832: Move and update sheltered accomodation question --- .../form/lettings/questions/sheltered.rb | 9 +++- .../subsections/property_information.rb | 1 + .../subsections/tenancy_information.rb | 2 +- .../2025/lettings/property_information.en.yml | 6 +++ .../2025/lettings/tenancy_information.en.yml | 6 --- .../form/lettings/questions/sheltered_spec.rb | 24 ++++++++++ .../subsections/property_information_spec.rb | 47 ++++++++++++++++++- .../subsections/tenancy_information_spec.rb | 24 +++++++++- 8 files changed, 109 insertions(+), 10 deletions(-) diff --git a/app/models/form/lettings/questions/sheltered.rb b/app/models/form/lettings/questions/sheltered.rb index 458772675..9127dfa6f 100644 --- a/app/models/form/lettings/questions/sheltered.rb +++ b/app/models/form/lettings/questions/sheltered.rb @@ -8,7 +8,14 @@ class Form::Lettings::Questions::Sheltered < ::Form::Question end def answer_options - if form.start_year_2024_or_later? + if form.start_year_2025_or_later? + { "1" => { "value" => "Yes – sheltered housing for tenants with low support needs" }, + "2" => { "value" => "Yes – extra care housing" }, + "7" => { "value" => "Yes - other" }, + "3" => { "value" => "No" }, + "divider" => { "value" => true }, + "4" => { "value" => "Don’t know" } } + elsif form.start_year_2024_or_later? { "1" => { "value" => "Yes – specialist retirement housing" }, "2" => { "value" => "Yes – extra care housing" }, "5" => { "value" => "Yes – sheltered housing for adults aged under 55 years" }, diff --git a/app/models/form/lettings/subsections/property_information.rb b/app/models/form/lettings/subsections/property_information.rb index c80e49e84..4d3e022c0 100644 --- a/app/models/form/lettings/subsections/property_information.rb +++ b/app/models/form/lettings/subsections/property_information.rb @@ -25,6 +25,7 @@ class Form::Lettings::Subsections::PropertyInformation < ::Form::Subsection Form::Lettings::Pages::VoidDateValueCheck.new(nil, nil, self), Form::Lettings::Pages::PropertyMajorRepairs.new(nil, nil, self), Form::Lettings::Pages::PropertyMajorRepairsValueCheck.new(nil, nil, self), + (Form::Lettings::Pages::ShelteredAccommodation.new(nil, nil, self) if form.start_year_2025_or_later?), ].flatten.compact end diff --git a/app/models/form/lettings/subsections/tenancy_information.rb b/app/models/form/lettings/subsections/tenancy_information.rb index f0b7f4bef..b65039b8d 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::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::ShelteredAccommodation.new(nil, nil, self), + (Form::Lettings::Pages::ShelteredAccommodation.new(nil, nil, self) unless form.start_year_2025_or_later?), ].flatten.compact end end diff --git a/config/locales/forms/2025/lettings/property_information.en.yml b/config/locales/forms/2025/lettings/property_information.en.yml index bf3f3532c..d32f1e0de 100644 --- a/config/locales/forms/2025/lettings/property_information.en.yml +++ b/config/locales/forms/2025/lettings/property_information.en.yml @@ -125,3 +125,9 @@ en: check_answer_label: "Completion date of repairs" hint_text: "" question_text: "When were the repairs completed?" + + sheltered: + page_header: "" + check_answer_label: "Is this letting in sheltered accommodation?" + hint_text: "Sheltered housing and special retirement housing are for tenants with low-level care and support needs. This typically provides some limited support to enable independent living, such as alarm-based assistance or a scheme manager.

Extra care housing is for tenants with medium to high care and support needs, often with 24 hour access to support staff provided by an agency registered with the Care Quality Commission." + question_text: "Is this letting in sheltered accommodation?" diff --git a/config/locales/forms/2025/lettings/tenancy_information.en.yml b/config/locales/forms/2025/lettings/tenancy_information.en.yml index 3276d1b3d..5d0c41dbb 100644 --- a/config/locales/forms/2025/lettings/tenancy_information.en.yml +++ b/config/locales/forms/2025/lettings/tenancy_information.en.yml @@ -58,9 +58,3 @@ en: check_answer_label: "Length of periodic tenancy" hint_text: "As this is a periodic tenancy, this question is optional. If you do not have the information available click save and continue" question_text: "What is the length of the periodic tenancy to the nearest year?" - - sheltered: - page_header: "" - check_answer_label: "Is this letting in sheltered accommodation?" - hint_text: "Sheltered housing and special retirement housing are for tenants with low-level care and support needs. This typically provides some limited support to enable independent living, such as alarm-based assistance or a scheme manager.

Extra care housing is for tenants with medium to high care and support needs, often with 24 hour access to support staff provided by an agency registered with the Care Quality Commission." - question_text: "Is this letting in sheltered accommodation?" diff --git a/spec/models/form/lettings/questions/sheltered_spec.rb b/spec/models/form/lettings/questions/sheltered_spec.rb index 1f21a92eb..00d145bf5 100644 --- a/spec/models/form/lettings/questions/sheltered_spec.rb +++ b/spec/models/form/lettings/questions/sheltered_spec.rb @@ -26,6 +26,11 @@ RSpec.describe Form::Lettings::Questions::Sheltered, type: :model do end context "with 2023/24 form" do + before do + allow(form).to receive(:start_year_2024_or_later?).and_return(false) + allow(form).to receive(:start_year_2025_or_later?).and_return(false) + end + it "has the correct answer_options" do expect(question.answer_options).to eq({ "2" => { "value" => "Yes – extra care housing" }, @@ -41,6 +46,7 @@ RSpec.describe Form::Lettings::Questions::Sheltered, type: :model do context "with 2024/25 form" do before do allow(form).to receive(:start_year_2024_or_later?).and_return(true) + allow(form).to receive(:start_year_2025_or_later?).and_return(false) end it "has the correct answer_options" do @@ -56,6 +62,24 @@ RSpec.describe Form::Lettings::Questions::Sheltered, type: :model do end end + context "with 2025/26 form" do + before do + allow(form).to receive(:start_year_2024_or_later?).and_return(true) + allow(form).to receive(:start_year_2025_or_later?).and_return(true) + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "1" => { "value" => "Yes – sheltered housing for tenants with low support needs" }, + "2" => { "value" => "Yes – extra care housing" }, + "7" => { "value" => "Yes - other" }, + "3" => { "value" => "No" }, + "divider" => { "value" => true }, + "4" => { "value" => "Don’t know" }, + }) + end + end + it "is not marked as derived" do expect(question.derived?(nil)).to be false end diff --git a/spec/models/form/lettings/subsections/property_information_spec.rb b/spec/models/form/lettings/subsections/property_information_spec.rb index cc12f621a..0d3a4e99b 100644 --- a/spec/models/form/lettings/subsections/property_information_spec.rb +++ b/spec/models/form/lettings/subsections/property_information_spec.rb @@ -14,12 +14,18 @@ RSpec.describe Form::Lettings::Subsections::PropertyInformation, type: :model do let(:form) { instance_double(Form, start_date:) } before do - allow(form).to receive(:start_year_2024_or_later?).and_return(false) + allow(form).to receive(:start_year_2024_or_later?).and_return(true) + allow(form).to receive(:start_year_2025_or_later?).and_return(false) end context "when 2023" do let(:start_date) { Time.utc(2023, 2, 8) } + before do + allow(form).to receive(:start_year_2024_or_later?).and_return(false) + allow(form).to receive(:start_year_2025_or_later?).and_return(false) + end + it "has correct pages" do expect(property_information.pages.map(&:id)).to eq( %w[ @@ -52,6 +58,44 @@ RSpec.describe Form::Lettings::Subsections::PropertyInformation, type: :model do before do allow(form).to receive(:start_year_2024_or_later?).and_return(true) + allow(form).to receive(:start_year_2025_or_later?).and_return(false) + end + + it "has correct pages" do + expect(property_information.pages.map(&:id)).to eq( + %w[ + uprn + uprn_confirmation + address_matcher + no_address_found + uprn_selection + address + property_local_authority + local_authority_rent_value_check + first_time_property_let_as_social_housing + property_let_type + property_vacancy_reason_not_first_let + property_vacancy_reason_first_let + property_unit_type + property_building_type + property_wheelchair_accessible + property_number_of_bedrooms + beds_rent_value_check + void_date + void_date_value_check + property_major_repairs + property_major_repairs_value_check + ], + ) + end + end + + context "when 2025" do + let(:start_date) { Time.utc(2025, 2, 8) } + + before do + allow(form).to receive(:start_year_2024_or_later?).and_return(true) + allow(form).to receive(:start_year_2025_or_later?).and_return(true) end it "has correct pages" do @@ -78,6 +122,7 @@ RSpec.describe Form::Lettings::Subsections::PropertyInformation, type: :model do void_date_value_check property_major_repairs property_major_repairs_value_check + sheltered_accommodation ], ) end diff --git a/spec/models/form/lettings/subsections/tenancy_information_spec.rb b/spec/models/form/lettings/subsections/tenancy_information_spec.rb index fce8e57fb..70663629c 100644 --- a/spec/models/form/lettings/subsections/tenancy_information_spec.rb +++ b/spec/models/form/lettings/subsections/tenancy_information_spec.rb @@ -16,12 +16,18 @@ RSpec.describe Form::Lettings::Subsections::TenancyInformation, type: :model do let(:form) { instance_double(Form, start_date:) } before do - allow(form).to receive(:start_year_2024_or_later?).and_return(false) + allow(form).to receive(:start_year_2024_or_later?).and_return(true) + allow(form).to receive(:start_year_2025_or_later?).and_return(false) end context "when 2023" do let(:start_date) { Time.utc(2023, 2, 8) } + before do + allow(form).to receive(:start_year_2024_or_later?).and_return(false) + allow(form).to receive(:start_year_2025_or_later?).and_return(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], @@ -34,6 +40,7 @@ RSpec.describe Form::Lettings::Subsections::TenancyInformation, type: :model do before do allow(form).to receive(:start_year_2024_or_later?).and_return(true) + allow(form).to receive(:start_year_2025_or_later?).and_return(false) end it "has correct pages" do @@ -42,6 +49,21 @@ RSpec.describe Form::Lettings::Subsections::TenancyInformation, type: :model do ) end end + + context "when 2025" do + let(:start_date) { Time.utc(2025, 2, 8) } + + before do + allow(form).to receive(:start_year_2024_or_later?).and_return(true) + allow(form).to receive(:start_year_2025_or_later?).and_return(true) + 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], + ) + end + end end it "has the correct id" do