diff --git a/app/models/derived_variables/sales_log_variables.rb b/app/models/derived_variables/sales_log_variables.rb index e182c2158..a1462454c 100644 --- a/app/models/derived_variables/sales_log_variables.rb +++ b/app/models/derived_variables/sales_log_variables.rb @@ -68,6 +68,10 @@ module DerivedVariables::SalesLogVariables self.la = nil end + if form.start_year_2025_or_later? && is_bedsit? + self.beds = 1 + end + self.nationality_all = nationality_all_group if nationality_uk_or_prefers_not_to_say? self.nationality_all_buyer2 = nationality_all_buyer2_group if nationality2_uk_or_prefers_not_to_say? diff --git a/app/models/form/sales/pages/property_building_type.rb b/app/models/form/sales/pages/property_building_type.rb index 40c8f3738..b9a829a64 100644 --- a/app/models/form/sales/pages/property_building_type.rb +++ b/app/models/form/sales/pages/property_building_type.rb @@ -2,6 +2,10 @@ class Form::Sales::Pages::PropertyBuildingType < ::Form::Page def initialize(id, hsh, subsection) super @id = "property_building_type" + @depends_on = [ + { "form.start_year_2025_or_later?" => false }, + { "is_staircase?" => false }, + ] end def questions diff --git a/app/models/form/sales/pages/property_number_of_bedrooms.rb b/app/models/form/sales/pages/property_number_of_bedrooms.rb index 796a617d5..a51cbfeca 100644 --- a/app/models/form/sales/pages/property_number_of_bedrooms.rb +++ b/app/models/form/sales/pages/property_number_of_bedrooms.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::PropertyNumberOfBedrooms < ::Form::Page def initialize(id, hsh, subsection) super @id = "property_number_of_bedrooms" + @depends_on = [{ "is_beds_inferred?" => false }] end def questions diff --git a/app/models/form/sales/pages/property_wheelchair_accessible.rb b/app/models/form/sales/pages/property_wheelchair_accessible.rb index a63964059..358f16d50 100644 --- a/app/models/form/sales/pages/property_wheelchair_accessible.rb +++ b/app/models/form/sales/pages/property_wheelchair_accessible.rb @@ -2,6 +2,10 @@ class Form::Sales::Pages::PropertyWheelchairAccessible < ::Form::Page def initialize(id, hsh, subsection) super @id = "property_wheelchair_accessible" + @depends_on = [ + { "form.start_year_2025_or_later?" => false }, + { "is_staircase?" => false }, + ] end def questions diff --git a/app/models/form/sales/pages/staircase.rb b/app/models/form/sales/pages/staircase.rb index 28b0d6b38..1413abadc 100644 --- a/app/models/form/sales/pages/staircase.rb +++ b/app/models/form/sales/pages/staircase.rb @@ -2,7 +2,8 @@ class Form::Sales::Pages::Staircase < ::Form::Page def initialize(id, hsh, subsection) super @id = "staircasing" - @copy_key = "sales.sale_information.staircasing" + @depends_on = [{ "ownershipsch" => 1 }] + @copy_key = "sales.#{subsection.id}.staircasing" end def questions diff --git a/app/models/form/sales/questions/staircase.rb b/app/models/form/sales/questions/staircase.rb index 9fc969735..6c98397ff 100644 --- a/app/models/form/sales/questions/staircase.rb +++ b/app/models/form/sales/questions/staircase.rb @@ -2,17 +2,25 @@ class Form::Sales::Questions::Staircase < ::Form::Question def initialize(id, hsh, page) super @id = "staircase" - @copy_key = "sales.sale_information.staircasing" + @copy_key = "sales.#{page.subsection.id}.staircasing" @type = "radio" - @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end - ANSWER_OPTIONS = { - "1" => { "value" => "Yes" }, - "2" => { "value" => "No" }, - "3" => { "value" => "Don’t know" }, - }.freeze + def answer_options + if form.start_year_2025_or_later? + { + "1" => { "value" => "Yes" }, + "2" => { "value" => "No" }, + }.freeze + else + { + "1" => { "value" => "Yes" }, + "2" => { "value" => "No" }, + "3" => { "value" => "Don’t know" }, + }.freeze + end + end QUESTION_NUMBER_FROM_YEAR = { 2023 => 76, 2024 => 78 }.freeze end diff --git a/app/models/form/sales/subsections/household_situation.rb b/app/models/form/sales/subsections/household_situation.rb index 225b1ae43..2e496908b 100644 --- a/app/models/form/sales/subsections/household_situation.rb +++ b/app/models/form/sales/subsections/household_situation.rb @@ -11,17 +11,9 @@ class Form::Sales::Subsections::HouseholdSituation < ::Form::Subsection Form::Sales::Pages::Buyer1PreviousTenure.new(nil, nil, self), Form::Sales::Pages::LastAccommodation.new(nil, nil, self), Form::Sales::Pages::LastAccommodationLa.new(nil, nil, self), - Form::Sales::Pages::BuyersOrganisations.new(nil, nil, self), - buyer_2_situation_pages, + (Form::Sales::Pages::BuyersOrganisations.new(nil, nil, self) unless form.start_year_2025_or_later?), + Form::Sales::Pages::Buyer2LivingIn.new(nil, nil, self), + Form::Sales::Pages::Buyer2PreviousHousingSituation.new(nil, nil, self), ].flatten.compact end - - def buyer_2_situation_pages - if form.start_date.year >= 2023 - [ - Form::Sales::Pages::Buyer2LivingIn.new(nil, nil, self), - Form::Sales::Pages::Buyer2PreviousHousingSituation.new(nil, nil, self), - ] - end - end end diff --git a/app/models/form/sales/subsections/property_information.rb b/app/models/form/sales/subsections/property_information.rb index 32df98af5..5d4021681 100644 --- a/app/models/form/sales/subsections/property_information.rb +++ b/app/models/form/sales/subsections/property_information.rb @@ -9,9 +9,10 @@ class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection def pages @pages ||= [ (uprn_questions if form.start_date.year >= 2024), + (Form::Sales::Pages::PropertyUnitType.new(nil, nil, self) if form.start_year_2025_or_later?), Form::Sales::Pages::PropertyNumberOfBedrooms.new(nil, nil, self), Form::Sales::Pages::AboutPriceValueCheck.new("about_price_bedrooms_value_check", nil, self), - Form::Sales::Pages::PropertyUnitType.new(nil, nil, self), + (Form::Sales::Pages::PropertyUnitType.new(nil, nil, self) unless form.start_year_2025_or_later?), Form::Sales::Pages::MonthlyChargesValueCheck.new("monthly_charges_property_type_value_check", nil, self), Form::Sales::Pages::PercentageDiscountValueCheck.new("percentage_discount_proptype_value_check", nil, self), Form::Sales::Pages::PropertyBuildingType.new(nil, nil, self), diff --git a/app/models/form/sales/subsections/setup.rb b/app/models/form/sales/subsections/setup.rb index 71d420f48..108fab4e8 100644 --- a/app/models/form/sales/subsections/setup.rb +++ b/app/models/form/sales/subsections/setup.rb @@ -13,11 +13,12 @@ class Form::Sales::Subsections::Setup < ::Form::Subsection Form::Sales::Pages::CreatedBy.new(nil, nil, self), Form::Sales::Pages::PurchaserCode.new(nil, nil, self), Form::Sales::Pages::OwnershipScheme.new(nil, nil, self), + (Form::Sales::Pages::Staircase.new(nil, nil, self) if form.start_year_2025_or_later?), Form::Sales::Pages::SharedOwnershipType.new(nil, nil, self), Form::Sales::Pages::DiscountedOwnershipType.new(nil, nil, self), (Form::Sales::Pages::OutrightOwnershipType.new(nil, nil, self) unless form.start_year_2025_or_later?), - (Form::Sales::Pages::BuyerCompany.new(nil, nil, self) unless form.start_year_2025_or_later?), - Form::Sales::Pages::BuyerLive.new(nil, nil, self), + (Form::Sales::Pages::BuyerCompany.new(nil, nil, self) unless form.start_year_2025_or_later?),======= + (Form::Sales::Pages::BuyerLive.new(nil, nil, self) unless form.start_year_2025_or_later?), Form::Sales::Pages::JointPurchase.new(nil, nil, self), Form::Sales::Pages::NumberJointBuyers.new(nil, nil, self), (Form::Sales::Pages::BuyerInterview.new("buyer_interview_joint_purchase", nil, self, joint_purchase: true) if form.start_year_2024_or_later?), diff --git a/app/models/form/sales/subsections/shared_ownership_scheme.rb b/app/models/form/sales/subsections/shared_ownership_scheme.rb index 3fba8ef70..455755e31 100644 --- a/app/models/form/sales/subsections/shared_ownership_scheme.rb +++ b/app/models/form/sales/subsections/shared_ownership_scheme.rb @@ -10,7 +10,7 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection @pages ||= [ Form::Sales::Pages::LivingBeforePurchase.new("living_before_purchase_shared_ownership_joint_purchase", nil, self, ownershipsch: 1, joint_purchase: true), Form::Sales::Pages::LivingBeforePurchase.new("living_before_purchase_shared_ownership", nil, self, ownershipsch: 1, joint_purchase: false), - Form::Sales::Pages::Staircase.new(nil, nil, self), + (Form::Sales::Pages::Staircase.new(nil, nil, self) unless form.start_year_2025_or_later?), Form::Sales::Pages::AboutStaircase.new("about_staircasing_joint_purchase", nil, self, joint_purchase: true), Form::Sales::Pages::AboutStaircase.new("about_staircasing_not_joint_purchase", nil, self, joint_purchase: false), Form::Sales::Pages::StaircaseBoughtValueCheck.new(nil, nil, self), diff --git a/app/models/sales_log.rb b/app/models/sales_log.rb index 23438142f..01741fbc5 100644 --- a/app/models/sales_log.rb +++ b/app/models/sales_log.rb @@ -396,6 +396,10 @@ class SalesLog < Log proptype == 2 end + def is_beds_inferred? + form.start_year_2025_or_later? && is_bedsit? + end + def shared_ownership_scheme? ownershipsch == 1 end diff --git a/app/services/bulk_upload/lettings/log_creator.rb b/app/services/bulk_upload/lettings/log_creator.rb index 3aaf1d69d..1fd0d45b6 100644 --- a/app/services/bulk_upload/lettings/log_creator.rb +++ b/app/services/bulk_upload/lettings/log_creator.rb @@ -15,7 +15,7 @@ class BulkUpload::Lettings::LogCreator row_parser.log.blank_invalid_non_setup_fields! row_parser.log.bulk_upload = bulk_upload - row_parser.log.creation_method_bulk_upload! + row_parser.log.creation_method = "bulk upload" row_parser.log.skip_update_status = true row_parser.log.status = "pending" row_parser.log.status_cache = row_parser.log.calculate_status diff --git a/app/services/bulk_upload/sales/log_creator.rb b/app/services/bulk_upload/sales/log_creator.rb index 2d0888e4d..ea337d220 100644 --- a/app/services/bulk_upload/sales/log_creator.rb +++ b/app/services/bulk_upload/sales/log_creator.rb @@ -14,7 +14,7 @@ class BulkUpload::Sales::LogCreator row_parser.log.blank_invalid_non_setup_fields! row_parser.log.bulk_upload = bulk_upload - row_parser.log.creation_method_bulk_upload! + row_parser.log.creation_method = "bulk upload" row_parser.log.skip_update_status = true row_parser.log.status = "pending" row_parser.log.status_cache = row_parser.log.calculate_status diff --git a/config/locales/forms/2025/sales/household_situation.en.yml b/config/locales/forms/2025/sales/household_situation.en.yml index 3aa3545d8..6b49a7d37 100644 --- a/config/locales/forms/2025/sales/household_situation.en.yml +++ b/config/locales/forms/2025/sales/household_situation.en.yml @@ -31,12 +31,6 @@ en: hint_text: "" question_text: "Select a local authority" - buyers_organisations: - page_header: "" - check_answer_label: "Organisations buyers were registered with" - hint_text: "Select all that apply. This question is optional. If no options are applicable, leave the options blank, and select save and continue." - question_text: "What organisations were the buyers registered with?" - buy2living: page_header: "" check_answer_label: "Buyer 2 living at the same address" diff --git a/config/locales/forms/2025/sales/property_information.en.yml b/config/locales/forms/2025/sales/property_information.en.yml index 240c96f09..d658362ea 100644 --- a/config/locales/forms/2025/sales/property_information.en.yml +++ b/config/locales/forms/2025/sales/property_information.en.yml @@ -69,7 +69,7 @@ en: beds: page_header: "" check_answer_label: "Number of bedrooms" - hint_text: "A bedsit has 1 bedroom." + hint_text: "" question_text: "How many bedrooms does the property have?" proptype: diff --git a/config/locales/forms/2025/sales/sale_information.en.yml b/config/locales/forms/2025/sales/sale_information.en.yml index 51270a92e..33826e58b 100644 --- a/config/locales/forms/2025/sales/sale_information.en.yml +++ b/config/locales/forms/2025/sales/sale_information.en.yml @@ -25,11 +25,6 @@ en: hint_text: "" question_text: "Did the buyer live in the property before purchasing it?" - staircasing: - page_header: "" - check_answer_label: "Staircasing transaction" - hint_text: "A staircasing transaction is when the household purchases more shares in their property, increasing the proportion they own and decreasing the proportion the housing association owns. Once the household purchases 100% of the shares, they own the property" - question_text: "Is this a staircasing transaction?" about_staircasing: page_header: "About the staircasing transaction" stairbought: diff --git a/config/locales/forms/2025/sales/setup.en.yml b/config/locales/forms/2025/sales/setup.en.yml index e1d99d477..6f7c5da98 100644 --- a/config/locales/forms/2025/sales/setup.en.yml +++ b/config/locales/forms/2025/sales/setup.en.yml @@ -39,6 +39,12 @@ en: hint_text: "" question_text: "Was this purchase made through an ownership scheme?" + staircasing: + page_header: "" + check_answer_label: "Staircasing transaction" + hint_text: "A staircasing transaction is when the household purchases more shares in their property, increasing the proportion they own and decreasing the proportion the housing association owns. Once the household purchases 100% of the shares, they own the property" + question_text: "Is this a staircasing transaction?" + type: shared_ownership: page_header: "Type of shared ownership sale" @@ -51,12 +57,6 @@ en: hint_text: "" question_text: "What is the type of discounted ownership sale?" - buylivein: - page_header: "" - check_answer_label: "Buyers living in property" - hint_text: "" - question_text: "Will any buyers live in the property?" - jointpur: page_header: "" check_answer_label: "Joint purchase" diff --git a/spec/factories/scheme.rb b/spec/factories/scheme.rb index 5f4ad30bc..77d74b70a 100644 --- a/spec/factories/scheme.rb +++ b/spec/factories/scheme.rb @@ -1,6 +1,6 @@ FactoryBot.define do factory :scheme do - service_name { Faker::Name.name } + service_name { "#{Faker::Name.name}'s Housing & Co." } sensitive { Faker::Number.within(range: 0..1) } registered_under_care_act { 1 } support_type { [0, 2, 3, 4, 5].sample } diff --git a/spec/models/form/sales/pages/property_building_type_spec.rb b/spec/models/form/sales/pages/property_building_type_spec.rb index aac8fbf24..b9c6bddca 100644 --- a/spec/models/form/sales/pages/property_building_type_spec.rb +++ b/spec/models/form/sales/pages/property_building_type_spec.rb @@ -5,7 +5,8 @@ RSpec.describe Form::Sales::Pages::PropertyBuildingType, type: :model do let(:page_id) { nil } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1))) } + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } + let(:subsection) { instance_double(Form::Subsection, enabled?: true, form:) } it "has correct subsection" do expect(page.subsection).to eq(subsection) @@ -22,4 +23,46 @@ RSpec.describe Form::Sales::Pages::PropertyBuildingType, type: :model do it "has the correct description" do expect(page.description).to be_nil end + + context "with form year 2024" do + let(:form) { Form.new(nil, 2024, [], "sales") } + let(:saledate) { Time.zone.local(2024, 4, 1) } + + context "with a staircasing log" do + let(:log) { build(:sales_log, :shared_ownership_setup_complete, staircase: 1, saledate:) } + + it "is routed to" do + expect(page.routed_to?(log, nil)).to be true + end + end + + context "with a non-staircasing log" do + let(:log) { build(:sales_log, staircase: nil, saledate:) } + + it "is routed to" do + expect(page.routed_to?(log, nil)).to be true + end + end + end + + context "with form year 2025" do + let(:form) { Form.new(nil, 2025, [], "sales") } + let(:saledate) { Time.zone.local(2025, 4, 1) } + + context "with a staircasing log" do + let(:log) { build(:sales_log, :shared_ownership_setup_complete, staircase: 1, saledate:) } + + it "is not routed to" do + expect(page.routed_to?(log, nil)).to be false + end + end + + context "with a non-staircasing log" do + let(:log) { build(:sales_log, staircase: nil, saledate:) } + + it "is routed to" do + expect(page.routed_to?(log, nil)).to be true + end + end + end end diff --git a/spec/models/form/sales/pages/property_wheelchair_accessible_spec.rb b/spec/models/form/sales/pages/property_wheelchair_accessible_spec.rb index 01dcb7ce7..bf0493a6d 100644 --- a/spec/models/form/sales/pages/property_wheelchair_accessible_spec.rb +++ b/spec/models/form/sales/pages/property_wheelchair_accessible_spec.rb @@ -5,11 +5,8 @@ RSpec.describe Form::Sales::Pages::PropertyWheelchairAccessible, type: :model do let(:page_id) { nil } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection) } - - before do - allow(subsection).to receive(:form).and_return(instance_double(Form, start_year_2024_or_later?: false, start_date: Time.zone.local(2023, 4, 1))) - end + let(:form) { instance_double(Form, start_year_2024_or_later?: false, start_date: Time.zone.local(2023, 4, 1)) } + let(:subsection) { instance_double(Form::Subsection, enabled?: true, form:) } it "has correct subsection" do expect(page.subsection).to eq(subsection) @@ -26,4 +23,46 @@ RSpec.describe Form::Sales::Pages::PropertyWheelchairAccessible, type: :model do it "has the correct description" do expect(page.description).to be_nil end + + context "with form year 2024" do + let(:form) { Form.new(nil, 2024, [], "sales") } + let(:saledate) { Time.zone.local(2024, 4, 1) } + + context "with a staircasing log" do + let(:log) { build(:sales_log, :shared_ownership_setup_complete, staircase: 1, saledate:) } + + it "is routed to" do + expect(page.routed_to?(log, nil)).to be true + end + end + + context "with a non-staircasing log" do + let(:log) { build(:sales_log, :shared_ownership_setup_complete, staircase: 2, saledate:) } + + it "is routed to" do + expect(page.routed_to?(log, nil)).to be true + end + end + end + + context "with form year 2025" do + let(:form) { Form.new(nil, 2025, [], "sales") } + let(:saledate) { Time.zone.local(2025, 4, 1) } + + context "with a staircasing log" do + let(:log) { build(:sales_log, :shared_ownership_setup_complete, staircase: 1, saledate:) } + + it "is not routed to" do + expect(page.routed_to?(log, nil)).to be false + end + end + + context "with a non-staircasing log" do + let(:log) { build(:sales_log, :shared_ownership_setup_complete, staircase: 2, saledate:) } + + it "is routed to" do + expect(page.routed_to?(log, nil)).to be true + end + end + end end diff --git a/spec/models/form/sales/pages/staircase_spec.rb b/spec/models/form/sales/pages/staircase_spec.rb index 6f17e7e89..3c26181c2 100644 --- a/spec/models/form/sales/pages/staircase_spec.rb +++ b/spec/models/form/sales/pages/staircase_spec.rb @@ -7,19 +7,39 @@ RSpec.describe Form::Sales::Pages::Staircase, type: :model do let(:page_definition) { nil } let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1))) } - it "has correct subsection" do - expect(page.subsection).to eq(subsection) - end + context "when start year is 2024" do + let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)), id: "sale_information") } - it "has correct questions" do - expect(page.questions.map(&:id)).to eq(%w[staircase]) - end + before do + allow(subsection.form).to receive(:start_year_2025_or_later?).and_return(false) + end + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[staircase]) + end - it "has the correct id" do - expect(page.id).to eq("staircasing") + it "has the correct id" do + expect(page.id).to eq("staircasing") + end + + it "has the correct description" do + expect(page.description).to be_nil + end end - it "has the correct description" do - expect(page.description).to be_nil + context "when start year is >= 2025" do + let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)), id: "setup") } + + before do + allow(subsection.form).to receive(:start_year_2025_or_later?).and_return(true) + end + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end end end diff --git a/spec/models/form/sales/questions/staircase_spec.rb b/spec/models/form/sales/questions/staircase_spec.rb index 7b45891da..29ba34d31 100644 --- a/spec/models/form/sales/questions/staircase_spec.rb +++ b/spec/models/form/sales/questions/staircase_spec.rb @@ -5,33 +5,55 @@ RSpec.describe Form::Sales::Questions::Staircase, type: :model do let(:question_id) { nil } let(:question_definition) { nil } - let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)))) } - it "has correct page" do - expect(question.page).to eq(page) - end + context "when start year is 2024" do + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2024, 4, 1)), id: "sale_information")) } - it "has the correct id" do - expect(question.id).to eq("staircase") - end + before do + allow(page.subsection.form).to receive(:start_year_2025_or_later?).and_return(false) + end - it "has the correct type" do - expect(question.type).to eq("radio") - end + it "has correct page" do + expect(question.page).to eq(page) + end - it "is not marked as derived" do - expect(question.derived?(nil)).to be false - end + it "has the correct id" do + expect(question.id).to eq("staircase") + end + + it "has the correct type" do + expect(question.type).to eq("radio") + end - it "has the correct answer_options" do - expect(question.answer_options).to eq({ - "1" => { "value" => "Yes" }, - "2" => { "value" => "No" }, - "3" => { "value" => "Don’t know" }, - }) + it "is not marked as derived" do + expect(question.derived?(nil)).to be false + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "1" => { "value" => "Yes" }, + "2" => { "value" => "No" }, + "3" => { "value" => "Don’t know" }, + }) + end + + it "has correct conditional for" do + expect(question.conditional_for).to eq(nil) + end end - it "has correct conditional for" do - expect(question.conditional_for).to eq(nil) + context "when start year is 2025" do + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2025, 4, 1)), id: "setup")) } + + before do + allow(page.subsection.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" }, + "2" => { "value" => "No" }, + }) + end end end diff --git a/spec/models/form/sales/subsections/household_situation_spec.rb b/spec/models/form/sales/subsections/household_situation_spec.rb index 10898b27c..903960a8d 100644 --- a/spec/models/form/sales/subsections/household_situation_spec.rb +++ b/spec/models/form/sales/subsections/household_situation_spec.rb @@ -3,16 +3,15 @@ require "rails_helper" RSpec.describe Form::Sales::Subsections::HouseholdSituation, type: :model do subject(:household_characteristics) { described_class.new(nil, nil, section) } - let(:start_date) { Time.utc(2023, 4, 1) } - let(:form) { instance_double(Form, start_date:) } + let(:form) { instance_double(Form, start_year_2024_or_later?: true, start_year_2025_or_later?: false) } let(:section) { instance_double(Form::Sales::Sections::Household, form:) } it "has correct section" do expect(household_characteristics.section).to eq(section) end - context "when the log belongs to the 22/23 collection" do - let(:start_date) { Time.utc(2022, 4, 1) } + context "when the start year is 2024" do + let(:form) { instance_double(Form, start_year_2024_or_later?: true, start_year_2025_or_later?: false) } it "has correct pages" do expect(household_characteristics.pages.map(&:id)).to eq( @@ -21,19 +20,22 @@ RSpec.describe Form::Sales::Subsections::HouseholdSituation, type: :model do last_accommodation last_accommodation_la buyers_organisations + buyer_2_living_in + buyer_2_previous_housing_situation ], ) end end - context "when the log belongs to the 23/24 collection" do + context "when the start year is 2025" do + let(:form) { instance_double(Form, start_year_2024_or_later?: true, start_year_2025_or_later?: true) } + it "has correct pages" do expect(household_characteristics.pages.map(&:id)).to eq( %w[ buyer1_previous_tenure last_accommodation last_accommodation_la - buyers_organisations buyer_2_living_in buyer_2_previous_housing_situation ], diff --git a/spec/models/form/sales/subsections/property_information_spec.rb b/spec/models/form/sales/subsections/property_information_spec.rb index d29ee85fe..ccfeb8e3a 100644 --- a/spec/models/form/sales/subsections/property_information_spec.rb +++ b/spec/models/form/sales/subsections/property_information_spec.rb @@ -15,6 +15,7 @@ RSpec.describe Form::Sales::Subsections::PropertyInformation, type: :model 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 context "when 2023" do @@ -48,6 +49,7 @@ RSpec.describe Form::Sales::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 @@ -75,6 +77,40 @@ RSpec.describe Form::Sales::Subsections::PropertyInformation, 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(property_information.pages.map(&:id)).to eq( + %w[ + uprn + uprn_confirmation + address_matcher + no_address_found + uprn_selection + address + property_local_authority + local_authority_buyer_1_income_max_value_check + local_authority_buyer_2_income_max_value_check + local_authority_combined_income_max_value_check + about_price_la_value_check + property_unit_type + property_number_of_bedrooms + about_price_bedrooms_value_check + monthly_charges_property_type_value_check + percentage_discount_proptype_value_check + property_building_type + property_wheelchair_accessible + ], + ) + end + end end it "has the correct id" do diff --git a/spec/models/form/sales/subsections/setup_spec.rb b/spec/models/form/sales/subsections/setup_spec.rb index 4e997b5c0..ad01ccd41 100644 --- a/spec/models/form/sales/subsections/setup_spec.rb +++ b/spec/models/form/sales/subsections/setup_spec.rb @@ -93,9 +93,9 @@ RSpec.describe Form::Sales::Subsections::Setup, type: :model do assigned_to purchaser_code ownership_scheme + staircasing shared_ownership_type discounted_ownership_type - buyer_live joint_purchase number_joint_buyers buyer_interview_joint_purchase diff --git a/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb b/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb index 8c5674d0b..4c546d58c 100644 --- a/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb +++ b/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb @@ -8,7 +8,7 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipScheme, type: :model do let(:section) { instance_double(Form::Sales::Sections::SaleInformation) } before do - allow(section).to receive(:form).and_return(instance_double(Form, start_year_2024_or_later?: false, start_date: Time.zone.local(2023, 4, 1))) + allow(section).to receive(:form).and_return(instance_double(Form, start_year_2024_or_later?: false, start_year_2025_or_later?: false, start_date: Time.zone.local(2023, 4, 1))) end it "has correct section" do diff --git a/spec/requests/locations_controller_spec.rb b/spec/requests/locations_controller_spec.rb index a7d7684f0..6de8e7d33 100644 --- a/spec/requests/locations_controller_spec.rb +++ b/spec/requests/locations_controller_spec.rb @@ -180,7 +180,7 @@ RSpec.describe LocationsController, type: :request do context "when signed in as a data coordinator user" do let(:user) { create(:user, :data_coordinator) } - let(:scheme) { create(:scheme, owning_organisation: user.organisation, service_name: "Some name") } + let(:scheme) { create(:scheme, owning_organisation: user.organisation) } let!(:locations) { create_list(:location, 3, scheme:, startdate: Time.zone.local(2022, 4, 1)) } before do @@ -215,7 +215,7 @@ RSpec.describe LocationsController, type: :request do end it "has correct title" do - expected_title = CGI.escapeHTML("#{scheme.service_name} - Submit social housing lettings and sales data (CORE) - GOV.UK") + expected_title = CGI.unescapeHTML("#{scheme.service_name} - Submit social housing lettings and sales data (CORE) - GOV.UK") expect(page).to have_title(expected_title) end @@ -232,7 +232,7 @@ RSpec.describe LocationsController, type: :request do end it "has correct page 1 of 2 title" do - expected_title = CGI.escapeHTML("#{scheme.service_name} (page 1 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") + expected_title = CGI.unescapeHTML("#{scheme.service_name} (page 1 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") expect(page).to have_title(expected_title) end @@ -254,7 +254,7 @@ RSpec.describe LocationsController, type: :request do end it "has correct page 2 of 2 title" do - expected_title = CGI.escapeHTML("#{scheme.service_name} (page 2 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") + expected_title = CGI.unescapeHTML("#{scheme.service_name} (page 2 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") expect(page).to have_title(expected_title) end @@ -287,7 +287,7 @@ RSpec.describe LocationsController, type: :request do end it "has search in the title" do - expected_title = CGI.escapeHTML("#{scheme.service_name} (1 location matching ‘#{search_param}’) - Submit social housing lettings and sales data (CORE) - GOV.UK") + expected_title = CGI.unescapeHTML("#{scheme.service_name} (1 location matching ‘#{search_param}’) - Submit social housing lettings and sales data (CORE) - GOV.UK") expect(page.title).to eq(expected_title) end end @@ -343,7 +343,7 @@ RSpec.describe LocationsController, type: :request do end it "has correct title" do - expected_title = CGI.escapeHTML("#{scheme.service_name} - Submit social housing lettings and sales data (CORE) - GOV.UK") + expected_title = CGI.unescapeHTML("#{scheme.service_name} - Submit social housing lettings and sales data (CORE) - GOV.UK") expect(page).to have_title(expected_title) end @@ -360,7 +360,7 @@ RSpec.describe LocationsController, type: :request do end it "has correct page 1 of 2 title" do - expected_title = CGI.escapeHTML("#{scheme.service_name} (page 1 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") + expected_title = CGI.unescapeHTML("#{scheme.service_name} (page 1 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") expect(page).to have_title(expected_title) end @@ -382,7 +382,7 @@ RSpec.describe LocationsController, type: :request do end it "has correct page 1 of 2 title" do - expected_title = CGI.escapeHTML("#{scheme.service_name} (page 2 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") + expected_title = CGI.unescapeHTML("#{scheme.service_name} (page 2 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") expect(page).to have_title(expected_title) end @@ -415,7 +415,7 @@ RSpec.describe LocationsController, type: :request do end it "has search in the title" do - expected_title = CGI.escapeHTML("#{scheme.service_name} (1 location matching ‘#{search_param}’) - Submit social housing lettings and sales data (CORE) - GOV.UK") + expected_title = CGI.unescapeHTML("#{scheme.service_name} (1 location matching ‘#{search_param}’) - Submit social housing lettings and sales data (CORE) - GOV.UK") expect(page).to have_title(expected_title) end end