From b759d29958a54b29df5812156b049c023b0631f3 Mon Sep 17 00:00:00 2001 From: samyou-softwire Date: Fri, 24 Apr 2026 10:24:25 +0100 Subject: [PATCH] CLDC-4402: lettings subsections --- .../subsections/household_characteristics.rb | 22 ++- spec/models/form/lettings/pages/uprn_spec.rb | 23 +-- .../form/lettings/questions/rsnvac_spec.rb | 152 ++++++------------ 3 files changed, 66 insertions(+), 131 deletions(-) diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb index e732dec70..912c21eb4 100644 --- a/app/models/form/sales/subsections/household_characteristics.rb +++ b/app/models/form/sales/subsections/household_characteristics.rb @@ -15,13 +15,9 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection def pages @pages ||= [ - (Form::Sales::Pages::BuyerInterview.new("buyer_interview_joint_purchase", nil, self, joint_purchase: true) unless form.start_year_2024_or_later?), - (Form::Sales::Pages::BuyerInterview.new("buyer_interview", nil, self, joint_purchase: false) unless form.start_year_2024_or_later?), - (Form::Sales::Pages::PrivacyNotice.new("privacy_notice_joint_purchase", nil, self, joint_purchase: true) unless form.start_year_2024_or_later?), - (Form::Sales::Pages::PrivacyNotice.new("privacy_notice", nil, self, joint_purchase: false) unless form.start_year_2024_or_later?), Form::Sales::Pages::Age1.new(nil, nil, self), Form::Sales::Pages::RetirementValueCheck.new("age_1_retirement_value_check", nil, self, person_index: 1), - (Form::Sales::Pages::NotRetiredValueCheck.new("age_1_not_retired_value_check", nil, self, person_index: 1) if form.start_year_2024_or_later?), + Form::Sales::Pages::NotRetiredValueCheck.new("age_1_not_retired_value_check", nil, self, person_index: 1), Form::Sales::Pages::OldPersonsSharedOwnershipValueCheck.new("age_1_old_persons_shared_ownership_joint_purchase_value_check", nil, self, joint_purchase: true), Form::Sales::Pages::OldPersonsSharedOwnershipValueCheck.new("age_1_old_persons_shared_ownership_value_check", nil, self, joint_purchase: false), (Form::Sales::Pages::SexRegisteredAtBirth1.new(nil, nil, self) if form.start_year_2026_or_later?), @@ -36,7 +32,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Sales::Pages::Buyer1Nationality.new(nil, nil, self), Form::Sales::Pages::Buyer1WorkingSituation.new(nil, nil, self), Form::Sales::Pages::RetirementValueCheck.new("working_situation_1_retirement_value_check", nil, self, person_index: 1), - (Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_1_not_retired_value_check", nil, self, person_index: 1) if form.start_year_2024_or_later?), + Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_1_not_retired_value_check", nil, self, person_index: 1), Form::Sales::Pages::Buyer1IncomeEcstatValueCheck.new("working_situation_buyer_1_income_value_check", nil, self), Form::Sales::Pages::Buyer1LiveInProperty.new(nil, nil, self), Form::Sales::Pages::BuyerLiveInValueCheck.new("buyer_1_live_in_property_value_check", nil, self, person_index: 1), @@ -46,7 +42,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Sales::Pages::OldPersonsSharedOwnershipValueCheck.new("age_2_old_persons_shared_ownership_joint_purchase_value_check", nil, self, joint_purchase: true), Form::Sales::Pages::OldPersonsSharedOwnershipValueCheck.new("age_2_old_persons_shared_ownership_value_check", nil, self, joint_purchase: false), Form::Sales::Pages::RetirementValueCheck.new("age_2_buyer_retirement_value_check", nil, self, person_index: 2), - (Form::Sales::Pages::NotRetiredValueCheck.new("age_2_buyer_not_retired_value_check", nil, self, person_index: 2) if form.start_year_2024_or_later?), + Form::Sales::Pages::NotRetiredValueCheck.new("age_2_buyer_not_retired_value_check", nil, self, person_index: 2), (Form::Sales::Pages::PersonStudentNotChildValueCheck.new("buyer_2_age_student_not_child_value_check", nil, self, person_index: 2) unless form.start_year_2025_or_later?), (Form::Sales::Pages::SexRegisteredAtBirth2.new(nil, nil, self) if form.start_year_2026_or_later?), (Form::Sales::Pages::Buyer2GenderSameAsSex.new(nil, nil, self) if form.start_year_2026_or_later?), @@ -54,7 +50,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection buyer_2_ethnicity_nationality_pages, Form::Sales::Pages::Buyer2WorkingSituation.new(nil, nil, self), Form::Sales::Pages::RetirementValueCheck.new("working_situation_2_retirement_value_check_joint_purchase", nil, self, person_index: 2), - (Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_2_not_retired_value_check_joint_purchase", nil, self, person_index: 2) if form.start_year_2024_or_later?), + Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_2_not_retired_value_check_joint_purchase", nil, self, person_index: 2), Form::Sales::Pages::Buyer2IncomeEcstatValueCheck.new("working_situation_buyer_2_income_value_check", nil, self), (Form::Sales::Pages::PersonStudentNotChildValueCheck.new("buyer_2_working_situation_student_not_child_value_check", nil, self, person_index: 2) unless form.start_year_2025_or_later?), Form::Sales::Pages::Buyer2LiveInProperty.new(nil, nil, self), @@ -69,20 +65,20 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection [ Form::Sales::Pages::PersonKnown.new("person_#{person_index}_known", nil, self, person_index:), (form.start_year_2025_or_later? ? Form::Sales::Pages::PersonRelationshipToBuyer1YesNo.new("person_#{person_index}_relationship_to_buyer_1", nil, self, person_index:) : Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_#{person_index}_relationship_to_buyer_1", nil, self, person_index:)), - (Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_#{person_index}_partner_under_16_value_check", nil, self, person_index:) if form.start_year_2024_or_later?), - (Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_#{person_index}_multiple_partners_value_check", nil, self, person_index:) if form.start_year_2024_or_later?), + Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_#{person_index}_partner_under_16_value_check", nil, self, person_index:), + Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_#{person_index}_multiple_partners_value_check", nil, self, person_index:), (Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_#{person_index}_student_not_child_value_check", nil, self, person_index:) unless form.start_year_2025_or_later?), Form::Sales::Pages::PersonAge.new("person_#{person_index}_age", nil, self, person_index:), Form::Sales::Pages::RetirementValueCheck.new("age_#{person_index}_retirement_value_check", nil, self, person_index:), - (Form::Sales::Pages::NotRetiredValueCheck.new("age_#{person_index}_not_retired_value_check", nil, self, person_index:) if form.start_year_2024_or_later?), + Form::Sales::Pages::NotRetiredValueCheck.new("age_#{person_index}_not_retired_value_check", nil, self, person_index:), (Form::Sales::Pages::PersonStudentNotChildValueCheck.new("age_#{person_index}_student_not_child_value_check", nil, self, person_index:) unless form.start_year_2025_or_later?), - (Form::Sales::Pages::PartnerUnder16ValueCheck.new("age_#{person_index}_partner_under_16_value_check", nil, self, person_index:) if form.start_year_2024_or_later?), + Form::Sales::Pages::PartnerUnder16ValueCheck.new("age_#{person_index}_partner_under_16_value_check", nil, self, person_index:), (Form::Sales::Pages::PersonGenderIdentity.new("person_#{person_index}_gender_identity", nil, self, person_index:) unless form.start_year_2026_or_later?), (Form::Sales::Pages::PersonSexRegisteredAtBirth.new("person_#{person_index}_sex_registered_at_birth", nil, self, person_index:) if form.start_year_2026_or_later?), (Form::Sales::Pages::PersonGenderSameAsSex.new("person_#{person_index}_gender_same_as_sex", nil, self, person_index:) if form.start_year_2026_or_later?), Form::Sales::Pages::PersonWorkingSituation.new("person_#{person_index}_working_situation", nil, self, person_index:), Form::Sales::Pages::RetirementValueCheck.new("working_situation_#{person_index}_retirement_value_check", nil, self, person_index:), - (Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_#{person_index}_not_retired_value_check", nil, self, person_index:) if form.start_year_2024_or_later?), + Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_#{person_index}_not_retired_value_check", nil, self, person_index:), (Form::Sales::Pages::PersonStudentNotChildValueCheck.new("working_situation_#{person_index}_student_not_child_value_check", nil, self, person_index:) unless form.start_year_2025_or_later?), ] end diff --git a/spec/models/form/lettings/pages/uprn_spec.rb b/spec/models/form/lettings/pages/uprn_spec.rb index 81f1aec40..c0495a1a1 100644 --- a/spec/models/form/lettings/pages/uprn_spec.rb +++ b/spec/models/form/lettings/pages/uprn_spec.rb @@ -1,15 +1,16 @@ require "rails_helper" RSpec.describe Form::Lettings::Pages::Uprn, type: :model do + include CollectionTimeHelper + subject(:page) { described_class.new(page_id, page_definition, subsection) } let(:page_id) { nil } let(:page_definition) { nil } let(:subsection) { instance_double(Form::Subsection) } - let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } + let(:form) { instance_double(Form, start_date: current_collection_start_date) } before do - allow(form).to receive(:start_year_2024_or_later?).and_return(false) allow(subsection).to receive(:form).and_return(form) end @@ -43,23 +44,7 @@ RSpec.describe Form::Lettings::Pages::Uprn, type: :model do context "when log is present" do let(:log) { build(:lettings_log) } - context "with 2023/24 form" do - it "points to address page" do - expect(page.skip_href(log)).to eq( - "address", - ) - end - - it "has correct skip_text" do - expect(page.skip_text).to eq("Enter address instead") - end - end - - context "with 2024/25 form" do - before do - allow(form).to receive(:start_year_2024_or_later?).and_return(true) - end - + context "with current form" do it "points to address search page" do expect(page.skip_href(log)).to eq( "address-matcher", diff --git a/spec/models/form/lettings/questions/rsnvac_spec.rb b/spec/models/form/lettings/questions/rsnvac_spec.rb index 9a63f1b23..598e6b2ff 100644 --- a/spec/models/form/lettings/questions/rsnvac_spec.rb +++ b/spec/models/form/lettings/questions/rsnvac_spec.rb @@ -1,16 +1,17 @@ require "rails_helper" RSpec.describe Form::Lettings::Questions::Rsnvac, type: :model do + include CollectionTimeHelper + subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } let(:question_definition) { nil } let(:page) { instance_double(Form::Page) } let(:subsection) { instance_double(Form::Subsection) } - let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } + let(:form) { instance_double(Form, start_date: current_collection_start_date) } before do - allow(form).to receive(:start_year_2024_or_later?).and_return(false) allow(page).to receive(:subsection).and_return(subsection) allow(subsection).to receive(:form).and_return(form) end @@ -31,107 +32,60 @@ RSpec.describe Form::Lettings::Questions::Rsnvac, type: :model do expect(question.derived?(nil)).to be false end - context "with 2023/24 form" do - it "has the correct answer_options" do - expect(question.answer_options).to eq({ - "13" => { - "value" => "Internal transfer", - "hint" => "Where a tenant moved from one social housing property to another property. Their landlord may be the same or may have changed.", - }, - "5" => { - "value" => "Previous tenant died with no succession", - }, - "9" => { - "value" => "Re-let to tenant who occupied same property as temporary accommodation", - }, - "14" => { - "value" => "Renewal of fixed-term tenancy", - "hint" => "To the same tenant in the same property, except if was previously used as temporary accommodation.", - }, - "19" => { - "value" => "Tenant involved in a succession downsize", - }, - "8" => { - "value" => "Tenant moved to private sector or other accommodation", - }, - "12" => { - "value" => "Tenant moved to other social housing provider", - }, - "18" => { - "value" => "Tenant moved to care home", - }, - "20" => { - "value" => "Tenant moved to long-stay hospital or similar institution", - }, - "6" => { - "value" => "Tenant abandoned property", - }, - "10" => { - "value" => "Tenant was evicted due to rent arrears", - }, - "11" => { - "value" => "Tenant was evicted due to anti-social behaviour", - }, - }) + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "14" => { + "value" => "Renewal of fixed-term tenancy", + "hint" => "To the same tenant in the same property, except if was previously used as temporary accommodation.", + }, + "9" => { + "value" => "Re-let to tenant who occupied same property as temporary accommodation", + }, + "13" => { + "value" => "Internal transfer", + "hint" => "Where a tenant moved from one social housing property to another property. Their landlord may be the same or may have changed.", + }, + "12" => { + "value" => "Tenant moved to other social housing provider", + }, + "8" => { + "value" => "Tenant moved to private sector or other accommodation", + }, + "18" => { + "value" => "Tenant moved to care home", + }, + "20" => { + "value" => "Tenant moved to long-stay hospital or similar institution", + }, + "5" => { + "value" => "Tenant died with no succession", + }, + "19" => { + "value" => "Tenant involved in a succession downsize", + }, + "6" => { + "value" => "Tenant abandoned property", + }, + "10" => { + "value" => "Tenant was evicted due to rent arrears", + }, + "11" => { + "value" => "Tenant was evicted due to anti-social behaviour", + }, + "21" => { + "value" => "Tenant was evicted due to both rent arrears and anti-social behaviour", + }, + "22" => { + "value" => "Any other reason", + }, + }) + + it "has the correct question number" do + expect(question.question_number).to eq(18) end end context "with 2024/25 form" do - let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } - - before do - allow(form).to receive(:start_year_2024_or_later?).and_return(true) - end - - it "has the correct answer_options" do - expect(question.answer_options).to eq({ - "14" => { - "value" => "Renewal of fixed-term tenancy", - "hint" => "To the same tenant in the same property, except if was previously used as temporary accommodation.", - }, - "9" => { - "value" => "Re-let to tenant who occupied same property as temporary accommodation", - }, - "13" => { - "value" => "Internal transfer", - "hint" => "Where a tenant moved from one social housing property to another property. Their landlord may be the same or may have changed.", - }, - "12" => { - "value" => "Tenant moved to other social housing provider", - }, - "8" => { - "value" => "Tenant moved to private sector or other accommodation", - }, - "18" => { - "value" => "Tenant moved to care home", - }, - "20" => { - "value" => "Tenant moved to long-stay hospital or similar institution", - }, - "5" => { - "value" => "Tenant died with no succession", - }, - "19" => { - "value" => "Tenant involved in a succession downsize", - }, - "6" => { - "value" => "Tenant abandoned property", - }, - "10" => { - "value" => "Tenant was evicted due to rent arrears", - }, - "11" => { - "value" => "Tenant was evicted due to anti-social behaviour", - }, - "21" => { - "value" => "Tenant was evicted due to both rent arrears and anti-social behaviour", - }, - "22" => { - "value" => "Any other reason", - }, - }) - end - it "has the correct question number" do expect(question.question_number).to eq(18) end