Browse Source

Merge branch 'main' into CLDC-3717-Sales-remove-q9

pull/2755/head
Manny Dinssa 1 year ago committed by GitHub
parent
commit
814d152444
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      app/models/derived_variables/sales_log_variables.rb
  2. 4
      app/models/form/sales/pages/property_building_type.rb
  3. 1
      app/models/form/sales/pages/property_number_of_bedrooms.rb
  4. 4
      app/models/form/sales/pages/property_wheelchair_accessible.rb
  5. 3
      app/models/form/sales/pages/staircase.rb
  6. 22
      app/models/form/sales/questions/staircase.rb
  7. 14
      app/models/form/sales/subsections/household_situation.rb
  8. 3
      app/models/form/sales/subsections/property_information.rb
  9. 5
      app/models/form/sales/subsections/setup.rb
  10. 2
      app/models/form/sales/subsections/shared_ownership_scheme.rb
  11. 4
      app/models/sales_log.rb
  12. 2
      app/services/bulk_upload/lettings/log_creator.rb
  13. 2
      app/services/bulk_upload/sales/log_creator.rb
  14. 6
      config/locales/forms/2025/sales/household_situation.en.yml
  15. 2
      config/locales/forms/2025/sales/property_information.en.yml
  16. 5
      config/locales/forms/2025/sales/sale_information.en.yml
  17. 12
      config/locales/forms/2025/sales/setup.en.yml
  18. 2
      spec/factories/scheme.rb
  19. 45
      spec/models/form/sales/pages/property_building_type_spec.rb
  20. 49
      spec/models/form/sales/pages/property_wheelchair_accessible_spec.rb
  21. 40
      spec/models/form/sales/pages/staircase_spec.rb
  22. 64
      spec/models/form/sales/questions/staircase_spec.rb
  23. 14
      spec/models/form/sales/subsections/household_situation_spec.rb
  24. 36
      spec/models/form/sales/subsections/property_information_spec.rb
  25. 2
      spec/models/form/sales/subsections/setup_spec.rb
  26. 2
      spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb
  27. 18
      spec/requests/locations_controller_spec.rb

4
app/models/derived_variables/sales_log_variables.rb

@ -68,6 +68,10 @@ module DerivedVariables::SalesLogVariables
self.la = nil self.la = nil
end 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 = 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? self.nationality_all_buyer2 = nationality_all_buyer2_group if nationality2_uk_or_prefers_not_to_say?

4
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) def initialize(id, hsh, subsection)
super super
@id = "property_building_type" @id = "property_building_type"
@depends_on = [
{ "form.start_year_2025_or_later?" => false },
{ "is_staircase?" => false },
]
end end
def questions def questions

1
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) def initialize(id, hsh, subsection)
super super
@id = "property_number_of_bedrooms" @id = "property_number_of_bedrooms"
@depends_on = [{ "is_beds_inferred?" => false }]
end end
def questions def questions

4
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) def initialize(id, hsh, subsection)
super super
@id = "property_wheelchair_accessible" @id = "property_wheelchair_accessible"
@depends_on = [
{ "form.start_year_2025_or_later?" => false },
{ "is_staircase?" => false },
]
end end
def questions def questions

3
app/models/form/sales/pages/staircase.rb

@ -2,7 +2,8 @@ class Form::Sales::Pages::Staircase < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "staircasing" @id = "staircasing"
@copy_key = "sales.sale_information.staircasing" @depends_on = [{ "ownershipsch" => 1 }]
@copy_key = "sales.#{subsection.id}.staircasing"
end end
def questions def questions

22
app/models/form/sales/questions/staircase.rb

@ -2,17 +2,25 @@ class Form::Sales::Questions::Staircase < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "staircase" @id = "staircase"
@copy_key = "sales.sale_information.staircasing" @copy_key = "sales.#{page.subsection.id}.staircasing"
@type = "radio" @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] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end
ANSWER_OPTIONS = { def answer_options
"1" => { "value" => "Yes" }, if form.start_year_2025_or_later?
"2" => { "value" => "No" }, {
"3" => { "value" => "Don’t know" }, "1" => { "value" => "Yes" },
}.freeze "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 QUESTION_NUMBER_FROM_YEAR = { 2023 => 76, 2024 => 78 }.freeze
end end

14
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::Buyer1PreviousTenure.new(nil, nil, self),
Form::Sales::Pages::LastAccommodation.new(nil, nil, self), Form::Sales::Pages::LastAccommodation.new(nil, nil, self),
Form::Sales::Pages::LastAccommodationLa.new(nil, nil, self), Form::Sales::Pages::LastAccommodationLa.new(nil, nil, self),
Form::Sales::Pages::BuyersOrganisations.new(nil, nil, self), (Form::Sales::Pages::BuyersOrganisations.new(nil, nil, self) unless form.start_year_2025_or_later?),
buyer_2_situation_pages, Form::Sales::Pages::Buyer2LivingIn.new(nil, nil, self),
Form::Sales::Pages::Buyer2PreviousHousingSituation.new(nil, nil, self),
].flatten.compact ].flatten.compact
end 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 end

3
app/models/form/sales/subsections/property_information.rb

@ -9,9 +9,10 @@ class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection
def pages def pages
@pages ||= [ @pages ||= [
(uprn_questions if form.start_date.year >= 2024), (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::PropertyNumberOfBedrooms.new(nil, nil, self),
Form::Sales::Pages::AboutPriceValueCheck.new("about_price_bedrooms_value_check", 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::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::PercentageDiscountValueCheck.new("percentage_discount_proptype_value_check", nil, self),
Form::Sales::Pages::PropertyBuildingType.new(nil, nil, self), Form::Sales::Pages::PropertyBuildingType.new(nil, nil, self),

5
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::CreatedBy.new(nil, nil, self),
Form::Sales::Pages::PurchaserCode.new(nil, nil, self), Form::Sales::Pages::PurchaserCode.new(nil, nil, self),
Form::Sales::Pages::OwnershipScheme.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::SharedOwnershipType.new(nil, nil, self),
Form::Sales::Pages::DiscountedOwnershipType.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::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::BuyerCompany.new(nil, nil, self) unless form.start_year_2025_or_later?),=======
Form::Sales::Pages::BuyerLive.new(nil, nil, self), (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::JointPurchase.new(nil, nil, self),
Form::Sales::Pages::NumberJointBuyers.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?), (Form::Sales::Pages::BuyerInterview.new("buyer_interview_joint_purchase", nil, self, joint_purchase: true) if form.start_year_2024_or_later?),

2
app/models/form/sales/subsections/shared_ownership_scheme.rb

@ -10,7 +10,7 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection
@pages ||= [ @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_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::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_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::AboutStaircase.new("about_staircasing_not_joint_purchase", nil, self, joint_purchase: false),
Form::Sales::Pages::StaircaseBoughtValueCheck.new(nil, nil, self), Form::Sales::Pages::StaircaseBoughtValueCheck.new(nil, nil, self),

4
app/models/sales_log.rb

@ -396,6 +396,10 @@ class SalesLog < Log
proptype == 2 proptype == 2
end end
def is_beds_inferred?
form.start_year_2025_or_later? && is_bedsit?
end
def shared_ownership_scheme? def shared_ownership_scheme?
ownershipsch == 1 ownershipsch == 1
end end

2
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.blank_invalid_non_setup_fields!
row_parser.log.bulk_upload = bulk_upload 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.skip_update_status = true
row_parser.log.status = "pending" row_parser.log.status = "pending"
row_parser.log.status_cache = row_parser.log.calculate_status row_parser.log.status_cache = row_parser.log.calculate_status

2
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.blank_invalid_non_setup_fields!
row_parser.log.bulk_upload = bulk_upload 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.skip_update_status = true
row_parser.log.status = "pending" row_parser.log.status = "pending"
row_parser.log.status_cache = row_parser.log.calculate_status row_parser.log.status_cache = row_parser.log.calculate_status

6
config/locales/forms/2025/sales/household_situation.en.yml

@ -31,12 +31,6 @@ en:
hint_text: "" hint_text: ""
question_text: "Select a local authority" 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: buy2living:
page_header: "" page_header: ""
check_answer_label: "Buyer 2 living at the same address" check_answer_label: "Buyer 2 living at the same address"

2
config/locales/forms/2025/sales/property_information.en.yml

@ -69,7 +69,7 @@ en:
beds: beds:
page_header: "" page_header: ""
check_answer_label: "Number of bedrooms" check_answer_label: "Number of bedrooms"
hint_text: "A bedsit has 1 bedroom." hint_text: ""
question_text: "How many bedrooms does the property have?" question_text: "How many bedrooms does the property have?"
proptype: proptype:

5
config/locales/forms/2025/sales/sale_information.en.yml

@ -25,11 +25,6 @@ en:
hint_text: "" hint_text: ""
question_text: "Did the buyer live in the property before purchasing it?" 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: about_staircasing:
page_header: "About the staircasing transaction" page_header: "About the staircasing transaction"
stairbought: stairbought:

12
config/locales/forms/2025/sales/setup.en.yml

@ -39,6 +39,12 @@ en:
hint_text: "" hint_text: ""
question_text: "Was this purchase made through an ownership scheme?" 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: type:
shared_ownership: shared_ownership:
page_header: "Type of shared ownership sale" page_header: "Type of shared ownership sale"
@ -51,12 +57,6 @@ en:
hint_text: "" hint_text: ""
question_text: "What is the type of discounted ownership sale?" 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: jointpur:
page_header: "" page_header: ""
check_answer_label: "Joint purchase" check_answer_label: "Joint purchase"

2
spec/factories/scheme.rb

@ -1,6 +1,6 @@
FactoryBot.define do FactoryBot.define do
factory :scheme do factory :scheme do
service_name { Faker::Name.name } service_name { "#{Faker::Name.name}'s Housing & Co." }
sensitive { Faker::Number.within(range: 0..1) } sensitive { Faker::Number.within(range: 0..1) }
registered_under_care_act { 1 } registered_under_care_act { 1 }
support_type { [0, 2, 3, 4, 5].sample } support_type { [0, 2, 3, 4, 5].sample }

45
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_id) { nil }
let(:page_definition) { 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 it "has correct subsection" do
expect(page.subsection).to eq(subsection) 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 it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end 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 end

49
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_id) { nil }
let(:page_definition) { nil } let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) } 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:) }
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
it "has correct subsection" do it "has correct subsection" do
expect(page.subsection).to eq(subsection) 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 it "has the correct description" do
expect(page.description).to be_nil expect(page.description).to be_nil
end 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 end

40
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(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1))) } let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1))) }
it "has correct subsection" do context "when start year is 2024" do
expect(page.subsection).to eq(subsection) let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)), id: "sale_information") }
end
it "has correct questions" do before do
expect(page.questions.map(&:id)).to eq(%w[staircase]) allow(subsection.form).to receive(:start_year_2025_or_later?).and_return(false)
end 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 it "has the correct id" do
expect(page.id).to eq("staircasing") expect(page.id).to eq("staircasing")
end
it "has the correct description" do
expect(page.description).to be_nil
end
end end
it "has the correct description" do context "when start year is >= 2025" do
expect(page.description).to be_nil 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
end end

64
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_id) { nil }
let(:question_definition) { 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 context "when start year is 2024" do
expect(question.page).to eq(page) 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")) }
end
it "has the correct id" do before do
expect(question.id).to eq("staircase") allow(page.subsection.form).to receive(:start_year_2025_or_later?).and_return(false)
end end
it "has the correct type" do it "has correct page" do
expect(question.type).to eq("radio") expect(question.page).to eq(page)
end end
it "is not marked as derived" do it "has the correct id" do
expect(question.derived?(nil)).to be false expect(question.id).to eq("staircase")
end end
it "has the correct type" do
expect(question.type).to eq("radio")
end
it "has the correct answer_options" do it "is not marked as derived" do
expect(question.answer_options).to eq({ expect(question.derived?(nil)).to be false
"1" => { "value" => "Yes" }, end
"2" => { "value" => "No" },
"3" => { "value" => "Don’t know" }, 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 end
it "has correct conditional for" do context "when start year is 2025" do
expect(question.conditional_for).to eq(nil) 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
end end

14
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 RSpec.describe Form::Sales::Subsections::HouseholdSituation, type: :model do
subject(:household_characteristics) { described_class.new(nil, nil, section) } subject(:household_characteristics) { described_class.new(nil, nil, section) }
let(:start_date) { Time.utc(2023, 4, 1) } let(:form) { instance_double(Form, start_year_2024_or_later?: true, start_year_2025_or_later?: false) }
let(:form) { instance_double(Form, start_date:) }
let(:section) { instance_double(Form::Sales::Sections::Household, form:) } let(:section) { instance_double(Form::Sales::Sections::Household, form:) }
it "has correct section" do it "has correct section" do
expect(household_characteristics.section).to eq(section) expect(household_characteristics.section).to eq(section)
end end
context "when the log belongs to the 22/23 collection" do context "when the start year is 2024" do
let(:start_date) { Time.utc(2022, 4, 1) } let(:form) { instance_double(Form, start_year_2024_or_later?: true, start_year_2025_or_later?: false) }
it "has correct pages" do it "has correct pages" do
expect(household_characteristics.pages.map(&:id)).to eq( 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
last_accommodation_la last_accommodation_la
buyers_organisations buyers_organisations
buyer_2_living_in
buyer_2_previous_housing_situation
], ],
) )
end end
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 it "has correct pages" do
expect(household_characteristics.pages.map(&:id)).to eq( expect(household_characteristics.pages.map(&:id)).to eq(
%w[ %w[
buyer1_previous_tenure buyer1_previous_tenure
last_accommodation last_accommodation
last_accommodation_la last_accommodation_la
buyers_organisations
buyer_2_living_in buyer_2_living_in
buyer_2_previous_housing_situation buyer_2_previous_housing_situation
], ],

36
spec/models/form/sales/subsections/property_information_spec.rb

@ -15,6 +15,7 @@ RSpec.describe Form::Sales::Subsections::PropertyInformation, type: :model do
before do 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(false)
allow(form).to receive(:start_year_2025_or_later?).and_return(false)
end end
context "when 2023" do context "when 2023" do
@ -48,6 +49,7 @@ RSpec.describe Form::Sales::Subsections::PropertyInformation, type: :model do
before do before do
allow(form).to receive(:start_year_2024_or_later?).and_return(true) 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 end
it "has correct pages" do it "has correct pages" do
@ -75,6 +77,40 @@ RSpec.describe Form::Sales::Subsections::PropertyInformation, type: :model do
) )
end end
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 end
it "has the correct id" do it "has the correct id" do

2
spec/models/form/sales/subsections/setup_spec.rb

@ -93,9 +93,9 @@ RSpec.describe Form::Sales::Subsections::Setup, type: :model do
assigned_to assigned_to
purchaser_code purchaser_code
ownership_scheme ownership_scheme
staircasing
shared_ownership_type shared_ownership_type
discounted_ownership_type discounted_ownership_type
buyer_live
joint_purchase joint_purchase
number_joint_buyers number_joint_buyers
buyer_interview_joint_purchase buyer_interview_joint_purchase

2
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) } let(:section) { instance_double(Form::Sales::Sections::SaleInformation) }
before do 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 end
it "has correct section" do it "has correct section" do

18
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 context "when signed in as a data coordinator user" do
let(:user) { create(:user, :data_coordinator) } 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)) } let!(:locations) { create_list(:location, 3, scheme:, startdate: Time.zone.local(2022, 4, 1)) }
before do before do
@ -215,7 +215,7 @@ RSpec.describe LocationsController, type: :request do
end end
it "has correct title" do 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) expect(page).to have_title(expected_title)
end end
@ -232,7 +232,7 @@ RSpec.describe LocationsController, type: :request do
end end
it "has correct page 1 of 2 title" do 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) expect(page).to have_title(expected_title)
end end
@ -254,7 +254,7 @@ RSpec.describe LocationsController, type: :request do
end end
it "has correct page 2 of 2 title" do 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) expect(page).to have_title(expected_title)
end end
@ -287,7 +287,7 @@ RSpec.describe LocationsController, type: :request do
end end
it "has search in the title" do 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) expect(page.title).to eq(expected_title)
end end
end end
@ -343,7 +343,7 @@ RSpec.describe LocationsController, type: :request do
end end
it "has correct title" do 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) expect(page).to have_title(expected_title)
end end
@ -360,7 +360,7 @@ RSpec.describe LocationsController, type: :request do
end end
it "has correct page 1 of 2 title" do 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) expect(page).to have_title(expected_title)
end end
@ -382,7 +382,7 @@ RSpec.describe LocationsController, type: :request do
end end
it "has correct page 1 of 2 title" do 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) expect(page).to have_title(expected_title)
end end
@ -415,7 +415,7 @@ RSpec.describe LocationsController, type: :request do
end end
it "has search in the title" do 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) expect(page).to have_title(expected_title)
end end
end end

Loading…
Cancel
Save