Browse Source

Merge branch 'main' into CLDC-3738-sales-household-characteristics-update-q29-and-q38

pull/2774/head
Manny Dinssa 9 months ago committed by GitHub
parent
commit
cb87e5800e
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. 14
      app/models/form/sales/subsections/household_situation.rb
  6. 3
      app/models/form/sales/subsections/property_information.rb
  7. 4
      app/models/sales_log.rb
  8. 2
      app/services/bulk_upload/lettings/log_creator.rb
  9. 2
      app/services/bulk_upload/sales/log_creator.rb
  10. 6
      config/locales/forms/2025/sales/household_situation.en.yml
  11. 2
      config/locales/forms/2025/sales/property_information.en.yml
  12. 2
      spec/factories/scheme.rb
  13. 45
      spec/models/form/sales/pages/property_building_type_spec.rb
  14. 49
      spec/models/form/sales/pages/property_wheelchair_accessible_spec.rb
  15. 14
      spec/models/form/sales/subsections/household_situation_spec.rb
  16. 36
      spec/models/form/sales/subsections/property_information_spec.rb
  17. 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
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?

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)
super
@id = "property_building_type"
@depends_on = [
{ "form.start_year_2025_or_later?" => false },
{ "is_staircase?" => false },
]
end
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)
super
@id = "property_number_of_bedrooms"
@depends_on = [{ "is_beds_inferred?" => false }]
end
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)
super
@id = "property_wheelchair_accessible"
@depends_on = [
{ "form.start_year_2025_or_later?" => false },
{ "is_staircase?" => false },
]
end
def questions

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::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

3
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),

4
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

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.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

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.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

6
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"

2
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:

2
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 }

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_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

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_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

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
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
],

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
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

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
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

Loading…
Cancel
Save