Browse Source

Merge branch 'main' into CLDC-4141-lettings-sab-question

pull/3156/head
Nat Dean-Lewis 2 weeks ago
parent
commit
82b5262ba4
  1. 4
      app/helpers/collection_time_helper.rb
  2. 24
      app/models/form/lettings/pages/working_situation_illness_check.rb
  3. 23
      app/models/form/lettings/pages/working_situation_illness_check_lead.rb
  4. 24
      app/models/form/lettings/pages/working_situation_illness_check_person.rb
  5. 13
      app/models/form/lettings/questions/working_situation_illness_check.rb
  6. 8
      app/models/form/lettings/subsections/household_characteristics.rb
  7. 1
      app/models/form/lettings/subsections/household_needs.rb
  8. 16
      app/models/validations/soft_validations.rb
  9. 9
      config/locales/forms/2026/lettings/soft_validations.en.yml
  10. 5
      db/migrate/20260107171455_add_working_situation_illness_check_to_lettings_logs.rb
  11. 19
      db/schema.rb
  12. 6
      spec/fixtures/files/lettings_log_csv_export_codes_26.csv
  13. 6
      spec/fixtures/files/lettings_log_csv_export_labels_26.csv
  14. 229
      spec/fixtures/variable_definitions/lettings_download_26_27.csv
  15. 2
      spec/lib/tasks/log_variable_definitions_spec.rb
  16. 49
      spec/models/form/lettings/questions/working_situation_illness_check_spec.rb
  17. 18
      spec/models/form/lettings/subsections/household_characteristics_spec.rb
  18. 66
      spec/models/form/lettings/subsections/household_needs_spec.rb
  19. 38
      spec/models/validations/soft_validations_spec.rb
  20. 2
      spec/services/bulk_upload/lettings/year2026/row_parser_spec.rb
  21. 73
      spec/shared/shared_log_examples.rb

4
app/helpers/collection_time_helper.rb

@ -50,6 +50,10 @@ module CollectionTimeHelper
next_collection_start_year + 1
end
def next_collection_start_date
current_collection_start_date + 1.year
end
def previous_collection_start_year
current_collection_start_year - 1
end

24
app/models/form/lettings/pages/working_situation_illness_check.rb

@ -0,0 +1,24 @@
class Form::Lettings::Pages::WorkingSituationIllnessCheck < ::Form::Page
def initialize(id, hsh, subsection)
super(id, hsh, subsection)
@id = "working_situation_long_term_illness_check"
@copy_key = "lettings.soft_validations.working_situation_illness_check"
@depends_on = [{ "at_least_one_working_situation_is_sickness_and_household_sickness_is_no?" => true }]
@title_text = {
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [],
}
@informative_text = {
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end
def questions
@questions ||= [Form::Lettings::Questions::WorkingSituationIllnessCheck.new(nil, nil, self, person_index: 0)]
end
def interruption_screen_question_ids
%w[illness ecstat1 ecstat2 ecstat3 ecstat4 ecstat5 ecstat6 ecstat7 ecstat8]
end
end

23
app/models/form/lettings/pages/working_situation_illness_check_lead.rb

@ -0,0 +1,23 @@
class Form::Lettings::Pages::WorkingSituationIllnessCheckLead < ::Form::Page
def initialize(id, hsh, subsection)
super(id, hsh, subsection)
@copy_key = "lettings.soft_validations.working_situation_illness_check"
@depends_on = [{ "at_least_one_working_situation_is_sickness_and_household_sickness_is_no?" => true }]
@title_text = {
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [],
}
@informative_text = {
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end
def questions
@questions ||= [Form::Lettings::Questions::WorkingSituationIllnessCheck.new(nil, nil, self, person_index: 1)]
end
def interruption_screen_question_ids
%w[illness ecstat1 ecstat2 ecstat3 ecstat4 ecstat5 ecstat6 ecstat7 ecstat8]
end
end

24
app/models/form/lettings/pages/working_situation_illness_check_person.rb

@ -0,0 +1,24 @@
class Form::Lettings::Pages::WorkingSituationIllnessCheckPerson < ::Form::Page
def initialize(id, hsh, subsection, person_index:)
super(id, hsh, subsection)
@copy_key = "lettings.soft_validations.working_situation_illness_check"
@depends_on = [{ "at_least_one_working_situation_is_sickness_and_household_sickness_is_no?" => true, "details_known_#{person_index}" => 0 }]
@title_text = {
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [],
}
@informative_text = {
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
@person_index = person_index
end
def questions
@questions ||= [Form::Lettings::Questions::WorkingSituationIllnessCheck.new(nil, nil, self, person_index: @person_index)]
end
def interruption_screen_question_ids
%w[illness ecstat1 ecstat2 ecstat3 ecstat4 ecstat5 ecstat6 ecstat7 ecstat8]
end
end

13
app/models/form/lettings/questions/working_situation_illness_check.rb

@ -0,0 +1,13 @@
class Form::Lettings::Questions::WorkingSituationIllnessCheck < ::Form::Question
def initialize(id, hsh, page, person_index:)
super(id, hsh, page)
@id = "working_situation_illness_check"
@copy_key = page.copy_key
@type = "interruption_screen"
@check_answers_card_number = person_index
@answer_options = ANSWER_OPTIONS
@hidden_in_check_answers = { "depends_on" => [{ "working_situation_illness_check" => 0 }, { "working_situation_illness_check" => 1 }] }
end
ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze
end

8
app/models/form/lettings/subsections/household_characteristics.rb

@ -32,6 +32,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::LeadTenantWorkingSituation.new(nil, nil, self),
Form::Lettings::Pages::LeadTenantUnderRetirementValueCheck.new("working_situation_lead_tenant_under_retirement_value_check", nil, self),
Form::Lettings::Pages::LeadTenantOverRetirementValueCheck.new("working_situation_lead_tenant_over_retirement_value_check", nil, self),
(Form::Lettings::Pages::WorkingSituationIllnessCheckLead.new("working_situation_lead_tenant_long_term_illness_check", nil, self) if form.start_year_2026_or_later?),
Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 2),
(Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 2) if form.start_year_2026_or_later?),
relationship_question(person_index: 2),
@ -54,6 +55,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 2),
Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("working_situation_2_under_retirement_value_check", nil, self, person_index: 2),
Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_2_over_retirement_value_check", nil, self, person_index: 2),
(Form::Lettings::Pages::WorkingSituationIllnessCheckPerson.new("working_situation_2_long_term_illness_check", nil, self, person_index: 2) if form.start_year_2026_or_later?),
Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 3),
(Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 3) if form.start_year_2026_or_later?),
relationship_question(person_index: 3),
@ -76,6 +78,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 3),
Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("working_situation_3_under_retirement_value_check", nil, self, person_index: 3),
Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_3_over_retirement_value_check", nil, self, person_index: 3),
(Form::Lettings::Pages::WorkingSituationIllnessCheckPerson.new("working_situation_3_long_term_illness_check", nil, self, person_index: 3) if form.start_year_2026_or_later?),
Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 4),
(Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 4) if form.start_year_2026_or_later?),
relationship_question(person_index: 4),
@ -98,6 +101,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 4),
Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("working_situation_4_under_retirement_value_check", nil, self, person_index: 4),
Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_4_over_retirement_value_check", nil, self, person_index: 4),
(Form::Lettings::Pages::WorkingSituationIllnessCheckPerson.new("working_situation_4_long_term_illness_check", nil, self, person_index: 4) if form.start_year_2026_or_later?),
Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 5),
(Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 5) if form.start_year_2026_or_later?),
relationship_question(person_index: 5),
@ -120,6 +124,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 5),
Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("working_situation_5_under_retirement_value_check", nil, self, person_index: 5),
Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_5_over_retirement_value_check", nil, self, person_index: 5),
(Form::Lettings::Pages::WorkingSituationIllnessCheckPerson.new("working_situation_5_long_term_illness_check", nil, self, person_index: 5) if form.start_year_2026_or_later?),
Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 6),
(Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 6) if form.start_year_2026_or_later?),
relationship_question(person_index: 6),
@ -142,6 +147,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 6),
Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("working_situation_6_under_retirement_value_check", nil, self, person_index: 6),
Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_6_over_retirement_value_check", nil, self, person_index: 6),
(Form::Lettings::Pages::WorkingSituationIllnessCheckPerson.new("working_situation_6_long_term_illness_check", nil, self, person_index: 6) if form.start_year_2026_or_later?),
Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 7),
(Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 7) if form.start_year_2026_or_later?),
relationship_question(person_index: 7),
@ -164,6 +170,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 7),
Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("working_situation_7_under_retirement_value_check", nil, self, person_index: 7),
Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_7_over_retirement_value_check", nil, self, person_index: 7),
(Form::Lettings::Pages::WorkingSituationIllnessCheckPerson.new("working_situation_7_long_term_illness_check", nil, self, person_index: 7) if form.start_year_2026_or_later?),
Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 8),
(Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 8) if form.start_year_2026_or_later?),
relationship_question(person_index: 8),
@ -186,6 +193,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 8),
Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("working_situation_8_under_retirement_value_check", nil, self, person_index: 8),
Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_8_over_retirement_value_check", nil, self, person_index: 8),
(Form::Lettings::Pages::WorkingSituationIllnessCheckPerson.new("working_situation_8_long_term_illness_check", nil, self, person_index: 8) if form.start_year_2026_or_later?),
].compact
end

1
app/models/form/lettings/subsections/household_needs.rb

@ -17,6 +17,7 @@ class Form::Lettings::Subsections::HouseholdNeeds < ::Form::Subsection
Form::Lettings::Pages::AccessNeedsExist.new("access_needs_exist", nil, self),
Form::Lettings::Pages::TypeOfAccessNeeds.new(nil, nil, self),
Form::Lettings::Pages::HealthConditions.new("health_conditions", nil, self),
(Form::Lettings::Pages::WorkingSituationIllnessCheck.new(nil, nil, self) if form.start_year_2026_or_later?),
Form::Lettings::Pages::HealthConditionEffects.new(nil, nil, self),
].compact
end

16
app/models/validations/soft_validations.rb

@ -215,6 +215,10 @@ module Validations::SoftValidations
(2..max_person_with_details).many? { |n| public_send("relat#{n}") == "P" }
end
def at_least_one_working_situation_is_sickness_and_household_sickness_is_no?
at_least_one_person_working_situation_is_illness? && no_one_in_household_with_illness?
end
private
def details_known_or_lead_tenant?(tenant_number)
@ -282,4 +286,16 @@ private
age < 16 && relationship == "P"
end
def at_least_one_person_working_situation_is_illness?
person_count = hhmemb || 8
(1..person_count).any? { |n| public_send("ecstat#{n}") == 8 }
end
def no_one_in_household_with_illness?
return unless illness
illness == 2
end
end

9
config/locales/forms/2026/lettings/soft_validations.en.yml

@ -146,3 +146,12 @@ en:
question_text: "We could not find an address that matches your search. You can search again or continue to enter the address manually."
title_text: "No address found"
informative_text: "We could not find an address that matches your search. You can search again or continue to enter the address manually."
working_situation_illness_check:
page_header: ""
check_answer_label: "Working situation illness confirmation"
check_answer_prompt: "Confirm 'unable to work due to illness' working situation and long-term illness warning"
hint_text: ""
question_text: "Are you sure this is correct?"
title_text: "You have said that at least one person's situation is 'Unable to work because of long-term sickness or disability'."
informative_text: "You also told us there is no-one in the household with a long-lasting health condition."

5
db/migrate/20260107171455_add_working_situation_illness_check_to_lettings_logs.rb

@ -0,0 +1,5 @@
class AddWorkingSituationIllnessCheckToLettingsLogs < ActiveRecord::Migration[7.2]
def change
add_column :lettings_logs, :working_situation_illness_check, :integer
end
end

19
db/schema.rb

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.2].define(version: 2026_01_28_121417) do
ActiveRecord::Schema[7.2].define(version: 2026_01_23_150201) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -84,7 +84,7 @@ ActiveRecord::Schema[7.2].define(version: 2026_01_28_121417) do
t.datetime "last_accessed"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.check_constraint "log_type::text = ANY (ARRAY['lettings'::character varying::text, 'sales'::character varying::text])", name: "log_type_check"
t.check_constraint "log_type::text = ANY (ARRAY['lettings'::character varying, 'sales'::character varying]::text[])", name: "log_type_check"
t.check_constraint "year >= 2000 AND year <= 2099", name: "year_check"
end
@ -375,14 +375,7 @@ ActiveRecord::Schema[7.2].define(version: 2026_01_28_121417) do
t.bigint "created_by_id"
t.boolean "manual_address_entry_selected", default: false
t.integer "referral_type"
t.string "sexrab1"
t.string "sexrab2"
t.string "sexrab3"
t.string "sexrab4"
t.string "sexrab5"
t.string "sexrab6"
t.string "sexrab7"
t.string "sexrab8"
t.integer "working_situation_illness_check"
t.index ["assigned_to_id"], name: "index_lettings_logs_on_assigned_to_id"
t.index ["bulk_upload_id"], name: "index_lettings_logs_on_bulk_upload_id"
t.index ["created_by_id"], name: "index_lettings_logs_on_created_by_id"
@ -795,12 +788,6 @@ ActiveRecord::Schema[7.2].define(version: 2026_01_28_121417) do
t.datetime "lasttransaction"
t.datetime "initialpurchase"
t.boolean "manual_address_entry_selected", default: false
t.string "sexrab1"
t.string "sexrab2"
t.string "sexrab3"
t.string "sexrab4"
t.string "sexrab5"
t.string "sexrab6"
t.index ["assigned_to_id"], name: "index_sales_logs_on_assigned_to_id"
t.index ["bulk_upload_id"], name: "index_sales_logs_on_bulk_upload_id"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id"

6
spec/fixtures/files/lettings_log_csv_export_codes_26.csv vendored

File diff suppressed because one or more lines are too long

6
spec/fixtures/files/lettings_log_csv_export_labels_26.csv vendored

File diff suppressed because one or more lines are too long

229
spec/fixtures/variable_definitions/lettings_download_26_27.csv vendored

@ -1,228 +1 @@
id,Log ID
status,Status of log
duplicate_set_id,ID of a set of duplicate logs
created_by,User the log is created by
is_dpo,Is the user in the assigned_to column the data protection officer?
created_at,Time and date the log was created
updated_by,User who last updated the log
updated_at,Time and date the log was last updated
creation_method,Was the log submitted in-service or via bulk upload?
collection_start_year,Year collection period opened
address_line1_as_entered,Address line 1 entered in bulk upload file
address_line2_as_entered,Address line 2 entered in bulk upload file
town_or_city_as_entered,Town or city entered in bulk upload file
county_as_entered,County entered in bulk upload file
postcode_full_as_entered,Postcode entered in bulk upload file
la_as_entered,Local authority entered in bulk upload file
bulk_upload_id,ID of a set of bulk uploaded logs
assigned_to,User the log is assigned to
owning_organisation_name,Which organisation owns this property?
managing_organisation_name,Which organisation manages this letting?
needstype,What is the needs type?
lettype,What is the letting type?
renewal,Is this letting a renewal?
startdate,What is the tenancy start date?
renttype,What is the rent type? (grouped into SR, IR or AR)
renttype_detail,What is the rent type?
irproduct,Which type of Intermediate Rent is this letting?
irproduct_other,Which 'Other' type of Intermediate Rent is this letting?
lar,Is this a London Affordable Rent letting?
tenancycode,What is the tenant code?
propcode,What is the property reference?
uprn_known,Is the UPRN known?
uprn,If known, property's UPRN
address_line1_input,Address line 1 input from address matching feature
postcode_full_input,Postcode input from address matching feature
address_search_value_check,Was the 'No address found' page seen?
uprn_selection,UPRN of the address selected
address_line1,Address line 1
address_line2,Address line 2
town_or_city,Town or City
county,County
postcode_full,Postcode
is_la_inferred,The internal value to indicate if the LA was inferred from the postcode
la_label,What is the property's local authority?
la,Local authority code
first_time_property_let_as_social_housing,Is this the first time the property has been let as social housing?
unitletas,What rent product was the property most recently let as?
rsnvac,What is the reason for the property being vacant?
newprop,Is this property new to the social rented sector?
unittype_gn,What type of unit is the property?
builtype,Which type of building is the property?
wchair,Is the property built or adapted to wheelchair-user standards?
beds,How many bedrooms does the property have?
voiddate,What is the void date?
vacdays,Number of days the property was vacant
void_date_value_check,The following soft validation was confirmed: You told us that the property has been vacant for more than 2 years. This is higher than we would expect.
majorrepairs,Were any major repairs carried out during the void period?
mrcdate,What date were any major repairs completed on?
major_repairs_date_value_check,The following soft validation was confirmed: You told us the property has been vacant for 2 years. This is higher than we would expect.
joint,Is this a joint tenancy?
startertenancy,Is this a starter tenancy?
tenancy,What is the type of tenancy?
tenancyother,If 'Other', what is the type of tenancy?
tenancylength,What is the length of the fixed-term tenancy to the nearest year?
sheltered,Is this letting in sheltered accommodation?
declaration,Has the tenant seen the MHCLG privacy notice?
hhmemb,How many people live in the household at this letting?
pregnancy_value_check,The following soft validation was confirmed: You told us somebody in the household is pregnant. You also told us there are no female tenants living at the property.
refused,Where household characteristics have a 'Refused' option for some or all of: AGE1-AGE8, SEX1-SEX8, RELAT2-RELAT8, ECSTAT1-ECSTAT8
hhtype,Type of household 1 = 1 elder; 2 = 2 adults, including elder(s); 3 = 1 adult; 4 = 2 adults; 5 = 1 adult & 1+ children; 6 = 2+ adults & 1+ children; 9 = Other
totchild,Total number of dependent children in the household (Sum of when RELAT2-8 = C)
totelder,Total number of elders in household (Sum of when AGE1-8 >= 60)
totadult,Total number of adults in household
age1,What is the lead tenant's age?
retirement_value_check,The following soft validation was confirmed: You told us this person is aged %{age} years and retired. The minimum expected retirement age for %{gender} in England is %{age}.
sexrab1,What was the lead tenant's sex at birth?
sex1,Which of these best describes the lead tenant's gender identity?
ethnic_group,What is the lead tenant's ethnic group?
ethnic,Which of these best describes the lead tenant's ethnic background?
nationality_all,What is the lead tenant's nationality?
ecstat1,Which of these best describes the lead tenant's working situation?
details_known_2,Are the details of tenant 2 known?
relat2,What is person 2's relationship to the lead tenant?
partner_under_16_value_check,The following soft validation was confirmed: You said that [person X]'s relationship to lead tenant is partner, and that their age is [AGEX]. Are you sure this is correct?
multiple_partners_value_check,The following soft validation was confirmed: You said that more than one person in the household is the partner of the lead tenant. Are you sure this is correct?
age2,What is person 2's age?
sexrab2,What was person 2's sex at birth?
sex2,Which of these best describes person 2's gender identity?
ecstat2,Which of these best describes person 2's working situation?
details_known_3,Are the details of tenant 3 known?
relat3,What is person 3's relationship to the lead tenant?
age3,What is person 3's age?
sexrab3,What was person 3's sex at birth?
sex3,Which of these best describes person 3's gender identity?
ecstat3,Which of these best describes person 3's working situation?
details_known_4,Are the details of tenant 4 known?
relat4,What is person 4's relationship to the lead tenant?
age4,What is person 4's age?
sexrab4,What was person 4's sex at birth?
sex4,Which of these best describes person 4's gender identity?
ecstat4,Which of these best describes person 4's working situation?
details_known_5,Are the details of tenant 5 known?
relat5,What is person 5's relationship to the lead tenant?
age5,What is person 5's age?
sexrab5,What was person 5's sex at birth?
sex5,Which of these best describes person 5's gender identity?
ecstat5,Which of these best describes person 5's working situation?
details_known_6,Are the details of tenant 6 known?
relat6,What is person 6's relationship to the lead tenant?
age6,What is person 6's age?
sexrab6,What was person 6's sex at birth?
sex6,Which of these best describes person 6's gender identity?
ecstat6,Which of these best describes person 6's working situation?
details_known_7,Are the details of tenant 7 known?
relat7,What is person 7's relationship to the lead tenant?
age7,What is person 7's age?
sexrab7,What was person 7's sex at birth?
sex7,Which of these best describes person 7's gender identity?
ecstat7,Which of these best describes person 7's working situation?
details_known_8,Are the details of tenant 8 known?
relat8,What is person 8's relationship to the lead tenant?
age8,What is person 8's age?
sexrab8,What was person 8's sex at birth?
sex8,Which of these best describes person 8's gender identity?
ecstat8,Which of these best describes person 8's working situation?
armedforces,Does anybody in the household have links to the UK armed forces?
leftreg,Is this person still serving in the UK armed forces?
reservist,Was this person seriously injured or ill as a result of serving in the UK armed forces?
preg_occ,Is anybody in the household pregnant?
housingneeds,Does anybody in the household have any disabled access needs?
housingneeds_type,What access needs do they have? (Fully wheelchair-accessible housing, Level access housing or Wheelchair access to essential rooms)
housingneeds_a,Disabled access needs a) Fully wheelchair-accessible housing
housingneeds_b,Disabled access needs b) Wheelchair access to essential rooms
housingneeds_c,Disabled access needs c) Level access housing
housingneeds_f,Disabled access needs f) Other disabled access needs
housingneeds_g,Disabled access needs g) No disabled access needs
housingneeds_h,Disabled access needs h) Don't know
housingneeds_other,Do they have any other disabled access needs?
illness,Does anybody in the household have a physical or mental health condition (or other illness) expected to last 12 months or more?
illness_type_4,Does this person's condition affect their dexterity?
illness_type_5,Does this person's condition affect their learning or understanding or concentrating?
illness_type_2,Does this person's condition affect their hearing?
illness_type_6,Does this person's condition affect their memory?
illness_type_7,Does this person's condition affect their mental health?
illness_type_3,Does this person's condition affect their mobility?
illness_type_9,Does this person's condition affect them socially or behaviourally?
illness_type_8,Does this person's condition affect their stamina or breathing or fatigue?
illness_type_1,Does this person's condition affect their vision?
illness_type_10,Does this person's condition affect them in another way?
layear,How long has the household continuously lived in the local authority area of the new letting?
waityear,How long has the household been on the local authority waiting list for the new letting?
reason,What is the tenant's main reason for the household leaving their last settled home?
reasonother,If 'Other', what was the main reason for leaving their last settled home?
reasonother_value_check,The soft validation was confirmed
prevten,Where was the household immediately before this letting?
homeless,Did the household experience homelessness immediately before this letting?
ppcodenk,Previous postcode unknown or previous accommodation was temporary
ppostcode_full,What is the postcode of the household's last settled home?
previous_la_known,Was the local authority of the household's last settled home known?
is_previous_la_inferred,The internal value to indicate if the previous LA was inferred from the postcode
prevloc_label,Previous location LA name
prevloc,Previous location's ONS LA Code
reasonpref,Was the household given reasonable preference by the local authority?
rp_homeless,Reasonable preference reason - They were homeless or about to lose their home (within 56 days)
rp_insan_unsat,Reasonable preference reason - They were living in insanitary, overcrowded or unisatisfactory housing
rp_medwel,Reasonable preference reason - They needed to move on medical and welfare reasons (including disability)
rp_hardship,Reasonable preference reason - They needed to move to avoid hardship to themselves or others
rp_dontknow,Reasonable preference reason - Don't Know
cbl,Was the letting made under Choice-Based Lettings (CBL)?
cap,Was the letting made under the Common Allocation Policy (CAP)?
chr,Was the letting made under the Common Housing Register (CHR)?
accessible_register,Was the letting made under the Accessible Register?
letting_allocation_none,The letting was not allocated under CBL, CAP, CHR or Accessible Register.
referral,What was the source of referral for this letting?
referral_value_check,The following soft validation was confirmed: Are you sure? This is a general needs log, and this referral type is for supported housing.
net_income_known,Do you know the household's combined income after tax?
incref,Was the household income refused?
earnings,How much income does the household have in total?
incfreq,How often does the household receive income?
net_income_value_check,Populated when someone hits the soft validation and confirmed in the service
hb,Is the tenant likely to be receiving any of these housing-related benefits?
has_benefits,Does the tenant receive housing-related benefits? Yes if hb = Universal Credit housing element or Housing benefit, No if hb = Don't Know, Neither, Tenant prefers not to say or blank
benefits,How much of the household's income is from Universal Credit, state pensions or benefits?
household_charge,Does the household pay rent or other charges for the accommodation?
nocharge,Does the household pay rent or other charges for the accommodation? - flag for when household_charge is answered no
period,How often does the household pay rent and other charges?
is_carehome,Is this accommodation a care home?
chcharge,If this is a care home, how much does the household pay every [time period]?
wchchrg,Weekly care home charge
carehome_charges_value_check,Populated when the soft validation and confirmed in the service
brent,What is the basic rent?
wrent,Weekly rent
rent_value_check,Populated when the soft validation and confirmed in the service
scharge,What is the service charge?
wscharge,Weekly service charge
pscharge,What is the personal service charge?
wpschrge,Weekly personal service charge
supcharg,What is the support charge?
wsupchrg,Weekly support charge
tcharge,Total charge to the tenant
wtcharge,Weekly total charge to the tenant
scharge_value_check,Populated when the soft validation and confirmed in the service
pscharge_value_check,Populated when the soft validation and confirmed in the service
supcharg_value_check,Populated when the soft validation and confirmed in the service
hbrentshortfall,After the household has received any housing-related benefits, will they still need to pay for rent and charges?
tshortfall_known,Can you estimate the outstanding amount?
tshortfall,Estimated outstanding amount
wtshortfall,Weekly total rent shortfall charge for tenant receiving housing benefit
scheme_code,What scheme does this letting belong to?
scheme_service_name,From scheme code, we map to the scheme name
scheme_confidential,Does the scheme contain confidential information?
SCHTYPE,What is this type of scheme? (Direct access hostel), Foyer, Housing for older people or Other supported housing
scheme_registered_under_care_act,Is this scheme registered under the Care Standards Act 2000?
scheme_owning_organisation_name,Which organisation owns the housing stock for this scheme?
scheme_primary_client_group,What client group is this scheme intended for?
scheme_has_other_client_group,Does this scheme provide for another client group?
scheme_secondary_client_group,What is the other client group?
scheme_support_type,What support does this scheme provide?
scheme_intended_stay,Intended length of stay
scheme_created_at,Date scheme was created
location_code,Which location is this letting for?
location_postcode,What is the postcode for this location?
location_name,What is the name of this location?
location_units,How many units are at this location?
location_type_of_unit,What is the most common type of unit at this location?
location_mobility_type,What are the mobility standards for the majority of the units in this location?
location_local_authority,What is the local authority of this postcode?
location_startdate,When did the first property in this location become available under this scheme?
working_situation_illness_check,The following soft validation was confirmed: You have said that at least one person's situation is 'Unable to work because of long-term sickness or disability'.

Can't render this file because it has a wrong number of fields in line 25.

2
spec/lib/tasks/log_variable_definitions_spec.rb

@ -6,7 +6,7 @@ RSpec.describe "log_variable_definitions" do
subject(:task) { Rake::Task["data_import:add_variable_definitions"] }
let(:path) { "spec/fixtures/variable_definitions" }
let(:total_variable_definitions_count) { 424 }
let(:total_variable_definitions_count) { 425 }
before do
Rake.application.rake_require("tasks/log_variable_definitions")

49
spec/models/form/lettings/questions/working_situation_illness_check_spec.rb

@ -0,0 +1,49 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::WorkingSituationIllnessCheck, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page, person_index: 1) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page, copy_key: nil) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct id" do
expect(question.id).to eq("working_situation_illness_check")
end
it "has the correct type" do
expect(question.type).to eq("interruption_screen")
end
it "is not marked as derived" do
expect(question.derived?(nil)).to be false
end
it "has a correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(1)
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
})
end
it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers).to eq({
"depends_on" => [
{
"working_situation_illness_check" => 0,
},
{
"working_situation_illness_check" => 1,
},
],
})
end
end

18
spec/models/form/lettings/subsections/household_characteristics_spec.rb

@ -10,17 +10,18 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
before do
allow(section).to receive(:form).and_return(form)
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(form).to receive(:start_year_2025_or_later?).and_return(false)
allow(form).to receive(:start_year_2026_or_later?).and_return(false)
end
it "has correct section" do
expect(household_characteristics.section).to eq(section)
end
context "with start year 2024" do
context "with start year 2024", metadata: { year: 24 } do
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(true)
allow(form).to receive(:start_year_2026_or_later?).and_return(false)
end
it "has correct pages" do
@ -172,11 +173,10 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
end
end
context "with start year 2025" do
context "with start year 2025", metadata: { year: 25 } do
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(true)
allow(form).to receive(:start_year_2025_or_later?).and_return(true)
allow(form).to receive(:start_year_2026_or_later?).and_return(false)
end
it "has correct pages" do
@ -328,7 +328,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
end
end
context "with start year >= 2026" do
context "with start year 2026", metadata: { year: 26 } do
before do
allow(form).to receive(:start_year_2024_or_later?).and_return(true)
allow(form).to receive(:start_year_2025_or_later?).and_return(true)
@ -361,6 +361,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
lead_tenant_working_situation
working_situation_lead_tenant_under_retirement_value_check
working_situation_lead_tenant_over_retirement_value_check
working_situation_lead_tenant_long_term_illness_check
person_2_known
person_2_age
person_2_lead_partner
@ -377,6 +378,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
person_2_working_situation
working_situation_2_under_retirement_value_check
working_situation_2_over_retirement_value_check
working_situation_2_long_term_illness_check
person_3_known
person_3_age
person_3_lead_partner
@ -393,6 +395,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
person_3_working_situation
working_situation_3_under_retirement_value_check
working_situation_3_over_retirement_value_check
working_situation_3_long_term_illness_check
person_4_known
person_4_age
person_4_lead_partner
@ -409,6 +412,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
person_4_working_situation
working_situation_4_under_retirement_value_check
working_situation_4_over_retirement_value_check
working_situation_4_long_term_illness_check
person_5_known
person_5_age
person_5_lead_partner
@ -425,6 +429,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
person_5_working_situation
working_situation_5_under_retirement_value_check
working_situation_5_over_retirement_value_check
working_situation_5_long_term_illness_check
person_6_known
person_6_age
person_6_lead_partner
@ -441,6 +446,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
person_6_working_situation
working_situation_6_under_retirement_value_check
working_situation_6_over_retirement_value_check
working_situation_6_long_term_illness_check
person_7_known
person_7_age
person_7_lead_partner
@ -457,6 +463,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
person_7_working_situation
working_situation_7_under_retirement_value_check
working_situation_7_over_retirement_value_check
working_situation_7_long_term_illness_check
person_8_known
person_8_age
person_8_lead_partner
@ -473,6 +480,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
person_8_working_situation
working_situation_8_under_retirement_value_check
working_situation_8_over_retirement_value_check
working_situation_8_long_term_illness_check
],
)
end

66
spec/models/form/lettings/subsections/household_needs_spec.rb

@ -8,25 +8,61 @@ RSpec.describe Form::Lettings::Subsections::HouseholdNeeds, type: :model do
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
let(:section) { instance_double(Form::Lettings::Sections::Household, form:) }
before do
allow(form).to receive(:start_year_2025_or_later?).and_return(false)
allow(form).to receive(:start_year_2026_or_later?).and_return(false)
end
it "has correct section" do
expect(household_needs.section).to eq(section)
end
it "has correct pages" do
expect(household_needs.pages.map(&:id)).to eq(
%w[
armed_forces
armed_forces_serving
armed_forces_injured
pregnant
no_females_pregnant_household_value_check
females_in_soft_age_range_in_pregnant_household_value_check
access_needs_exist
type_of_access_needs
health_conditions
health_condition_effects
],
)
context "with start year >= 2025", metadata: { year: 25 } do
before do
allow(form).to receive(:start_year_2025_or_later?).and_return(true)
end
it "has correct pages" do
expect(household_needs.pages.map(&:id)).to eq(
%w[
armed_forces
armed_forces_serving
armed_forces_injured
pregnant
no_females_pregnant_household_value_check
females_in_soft_age_range_in_pregnant_household_value_check
access_needs_exist
type_of_access_needs
health_conditions
health_condition_effects
],
)
end
end
context "with start year >= 2026", metadata: { year: 26 } do
before do
allow(form).to receive(:start_year_2025_or_later?).and_return(true)
allow(form).to receive(:start_year_2026_or_later?).and_return(true)
end
it "has correct pages" do
expect(household_needs.pages.map(&:id)).to eq(
%w[
armed_forces
armed_forces_serving
armed_forces_injured
pregnant
no_females_pregnant_household_value_check
females_in_soft_age_range_in_pregnant_household_value_check
access_needs_exist
type_of_access_needs
health_conditions
working_situation_long_term_illness_check
health_condition_effects
],
)
end
end
it "has the correct id" do

38
spec/models/validations/soft_validations_spec.rb

@ -1354,4 +1354,42 @@ RSpec.describe Validations::SoftValidations do
expect(record).to be_reasonother_might_be_existing_category
end
end
describe "at_least_one_working_situation_is_sickness_and_household_sickness_is_no" do
it "returns true if one person has working situation as illness and household sickness is no" do
record.illness = 2
record.hhmemb = 2
record.ecstat1 = 8
record.ecstat2 = 1
expect(record.at_least_one_working_situation_is_sickness_and_household_sickness_is_no?).to be true
end
it "returns true if all people has working situation as illness and household sickness is no" do
record.illness = 2
record.hhmemb = 2
record.ecstat1 = 8
record.ecstat2 = 8
expect(record.at_least_one_working_situation_is_sickness_and_household_sickness_is_no?).to be true
end
it "returns false if household sickness is yes" do
record.illness = 1
record.hhmemb = 2
record.ecstat1 = 8
record.ecstat2 = 1
expect(record.at_least_one_working_situation_is_sickness_and_household_sickness_is_no?).to be false
end
it "returns false if no working situation is illness" do
record.illness = 2
record.hhmemb = 2
record.ecstat1 = 1
record.ecstat2 = 1
expect(record.at_least_one_working_situation_is_sickness_and_household_sickness_is_no?).to be false
end
end
end

2
spec/services/bulk_upload/lettings/year2026/row_parser_spec.rb

@ -200,7 +200,7 @@ RSpec.describe BulkUpload::Lettings::Year2026::RowParser do
field_82: "1",
field_83: "0",
field_85: "2",
field_85: "3",
field_96: "11",
field_97: "2",

73
spec/shared/shared_log_examples.rb

@ -2,30 +2,57 @@ require "rails_helper"
# rubocop:disable RSpec/AnyInstance
RSpec.shared_examples "shared log examples" do |log_type|
describe "status" do
let(:empty_log) { create(log_type) }
let(:in_progress_log) { create(log_type, :in_progress) }
let(:completed_log) { create(log_type, :completed) }
it "is set to not started for an empty #{log_type} log" do
expect(empty_log.not_started?).to be(true)
expect(empty_log.in_progress?).to be(false)
expect(empty_log.completed?).to be(false)
expect(empty_log.deleted?).to be(false)
end
it "is set to in progress for a started #{log_type} log" do
expect(in_progress_log.in_progress?).to be(true)
expect(in_progress_log.not_started?).to be(false)
expect(in_progress_log.completed?).to be(false)
expect(in_progress_log.deleted?).to be(false)
end
include CollectionTimeHelper
it "is set to completed for a completed #{log_type} log" do
expect(completed_log.in_progress?).to be(false)
expect(completed_log.not_started?).to be(false)
expect(completed_log.completed?).to be(true)
expect(completed_log.deleted?).to be(false)
describe "status" do
[
{
start_date: :current_collection_start_date,
label: "current",
},
{
start_date: :next_collection_start_date,
label: "next",
},
].each do |scenario|
context "when creating a log for #{scenario[:label]} year" do
around do |example|
start_date = Timecop.return { send(scenario[:start_date]) }
Timecop.freeze(start_date) do
Singleton.__init__(FormHandler)
example.run
end
end
let(:empty_log) { create(log_type) }
let(:in_progress_log) { create(log_type, :in_progress) }
let(:completed_log) { create(log_type, :completed) }
it "is set to not started for an empty #{log_type} log" do
expect(empty_log.in_progress?).to be(false)
expect(empty_log.not_started?).to be(true)
expect(empty_log.completed?).to be(false)
expect(empty_log.deleted?).to be(false)
end
it "is set to in progress for a started #{log_type} log" do
expect(in_progress_log.in_progress?).to be(true)
expect(in_progress_log.not_started?).to be(false)
expect(in_progress_log.completed?).to be(false)
expect(in_progress_log.deleted?).to be(false)
end
# if this test starts failing, likely because a new question has been added
# and the :completed trait in spec/factories/lettings_log.rb (or sales_log.rb)
# needs to be updated to set the database col with that questions answer
it "is set to completed for a completed #{log_type} log" do
expect(completed_log.in_progress?).to be(false)
expect(completed_log.not_started?).to be(false)
expect(completed_log.completed?).to be(true)
expect(completed_log.deleted?).to be(false)
end
end
end
end

Loading…
Cancel
Save