From ce13bea9d82b808461617735d108ce9fc74656be Mon Sep 17 00:00:00 2001 From: Rebecca Jesson Date: Mon, 10 Aug 2026 15:22:19 +0100 Subject: [PATCH] CLDC-4402: simplify some start_year_2024_or_later uses p1 --- .../lettings_log_variables.rb | 4 +- .../derived_variables/sales_log_variables.rb | 4 +- .../lettings/pages/lead_tenant_nationality.rb | 14 +- app/models/form/lettings/pages/uprn.rb | 12 +- app/models/form/lettings/questions/age.rb | 4 +- .../form/lettings/questions/declaration.rb | 15 +- .../form/lettings/questions/ethnic_white.rb | 23 +-- ...rst_time_property_let_as_social_housing.rb | 4 +- .../lettings/questions/housingneeds_other.rb | 19 +-- .../form/lettings/questions/is_carehome.rb | 15 +- app/models/form/lettings/questions/layear.rb | 14 +- .../lettings/questions/letting_allocation.rb | 26 ++-- .../form/lettings/questions/nationality.rb | 23 --- .../lettings/questions/person_relationship.rb | 27 +--- .../lettings/questions/previous_let_type.rb | 12 -- .../form/lettings/questions/reason_renewal.rb | 31 ++-- .../questions/referral_general_needs_prp.rb | 132 ++++++------------ app/models/form/sales/pages/uprn.rb | 12 +- app/models/sales_log.rb | 7 +- .../lettings/questions/declaration_spec.rb | 59 ++------ .../lettings/questions/ethnic_white_spec.rb | 38 ++--- ...ime_property_let_as_social_housing_spec.rb | 32 ++--- .../questions/housingneeds_other_spec.rb | 34 ++--- .../lettings/questions/is_carehome_spec.rb | 30 ++-- .../form/lettings/questions/layear_spec.rb | 23 +-- .../questions/letting_allocation_spec.rb | 41 ++---- .../lettings/questions/nationality_spec.rb | 36 ----- .../questions/person_relationship_spec.rb | 6 +- .../questions/previous_let_type_spec.rb | 32 +---- .../lettings/questions/reason_renewal_spec.rb | 46 ++---- .../referral_general_needs_prp_spec.rb | 78 +++-------- 31 files changed, 219 insertions(+), 634 deletions(-) delete mode 100644 app/models/form/lettings/questions/nationality.rb delete mode 100644 spec/models/form/lettings/questions/nationality_spec.rb diff --git a/app/models/derived_variables/lettings_log_variables.rb b/app/models/derived_variables/lettings_log_variables.rb index 230b2a1dc..7756bf7d0 100644 --- a/app/models/derived_variables/lettings_log_variables.rb +++ b/app/models/derived_variables/lettings_log_variables.rb @@ -68,7 +68,7 @@ module DerivedVariables::LettingsLogVariables self.has_benefits = get_has_benefits self.tshortfall_known = 0 if tshortfall self.nocharge = household_charge # Nocharge: 0 = No, 1 = Yes, Household charge: 0 = Yes, 1 = No - if form.start_year_2024_or_later? && is_bedsit? + if is_bedsit? self.beds = 1 end if bedsit_changed_to_not_bedsit? # make user answer num of bedrooms again @@ -280,7 +280,7 @@ private self.wchair = nil self.location_id = nil end - if form.start_year_2024_or_later? && unittype_gn_changed? && unittype_gn_was == 2 + if unittype_gn_changed? && unittype_gn_was == 2 self.beds = nil end end diff --git a/app/models/derived_variables/sales_log_variables.rb b/app/models/derived_variables/sales_log_variables.rb index b93acedb6..71580b66d 100644 --- a/app/models/derived_variables/sales_log_variables.rb +++ b/app/models/derived_variables/sales_log_variables.rb @@ -29,7 +29,7 @@ module DerivedVariables::SalesLogVariables end end - if saledate && form.start_year_2024_or_later? && discounted_ownership_sale? + if saledate && discounted_ownership_sale? self.ppostcode_full = postcode_full self.ppcodenk = pcodenk self.prevloc = la @@ -44,7 +44,7 @@ module DerivedVariables::SalesLogVariables self.hhmemb = number_of_household_members self.hhtype = household_type - if saledate && form.start_year_2024_or_later? + if saledate self.soctenant = soctenant_from_prevten_values clear_child_ecstat_for_age_changes! child_under_16_constraints! diff --git a/app/models/form/lettings/pages/lead_tenant_nationality.rb b/app/models/form/lettings/pages/lead_tenant_nationality.rb index 410a6320f..9a3e51a07 100644 --- a/app/models/form/lettings/pages/lead_tenant_nationality.rb +++ b/app/models/form/lettings/pages/lead_tenant_nationality.rb @@ -2,18 +2,14 @@ class Form::Lettings::Pages::LeadTenantNationality < ::Form::Page def initialize(id, hsh, subsection) super @id = "lead_tenant_nationality" - @copy_key = "lettings.household_characteristics.#{form.start_year_2024_or_later? ? 'nationality_all' : 'national'}" + @copy_key = "lettings.household_characteristics.nationality_all" @depends_on = [{ "declaration" => 1 }] end def questions - @questions ||= if form.start_year_2024_or_later? - [ - Form::Lettings::Questions::NationalityAllGroup.new(nil, nil, self), - Form::Lettings::Questions::NationalityAll.new(nil, nil, self), - ] - else - [Form::Lettings::Questions::Nationality.new(nil, nil, self)] - end + @questions ||= [ + Form::Lettings::Questions::NationalityAllGroup.new(nil, nil, self), + Form::Lettings::Questions::NationalityAll.new(nil, nil, self), + ] end end diff --git a/app/models/form/lettings/pages/uprn.rb b/app/models/form/lettings/pages/uprn.rb index b9a3a4e94..4d3095a92 100644 --- a/app/models/form/lettings/pages/uprn.rb +++ b/app/models/form/lettings/pages/uprn.rb @@ -14,20 +14,12 @@ class Form::Lettings::Pages::Uprn < ::Form::Page end def skip_text - if form.start_year_2024_or_later? - "Search for address instead" - else - "Enter address instead" - end + "Search for address instead" end def skip_href(log = nil) return unless log - if form.start_year_2024_or_later? - "address-matcher" - else - "address" - end + "address-matcher" end end diff --git a/app/models/form/lettings/questions/age.rb b/app/models/form/lettings/questions/age.rb index 61e70fe05..010dd0e42 100644 --- a/app/models/form/lettings/questions/age.rb +++ b/app/models/form/lettings/questions/age.rb @@ -33,8 +33,6 @@ class Form::Lettings::Questions::Age < ::Form::Question end def hint_text - if form.start_year_2024_or_later? - "Answer 1 for children aged under 1 year old" - end + "Answer 1 for children aged under 1 year old" end end diff --git a/app/models/form/lettings/questions/declaration.rb b/app/models/form/lettings/questions/declaration.rb index 7c5c7ebdb..d94f85586 100644 --- a/app/models/form/lettings/questions/declaration.rb +++ b/app/models/form/lettings/questions/declaration.rb @@ -3,27 +3,16 @@ class Form::Lettings::Questions::Declaration < ::Form::Question super @id = "declaration" @type = "checkbox" - @check_answers_card_number = 0 unless form.start_year_2024_or_later? @top_guidance_partial = "privacy_notice_tenant" @question_number = get_question_number_from_hash(QUESTION_NUMBER_FROM_YEAR) end def answer_options - declaration_text = if form.start_year_2024_or_later? - "The tenant has seen or been given access to the MHCLG privacy notice" - else - "The tenant has seen the MHCLG privacy notice" - end - - { "declaration" => { "value" => declaration_text } }.freeze + { "declaration" => { "value" => "The tenant has seen or been given access to the MHCLG privacy notice" } }.freeze end def unanswered_error_message(_log = nil) - if form.start_year_2024_or_later? - I18n.t("validations.declaration.missing.post_2024") - else - I18n.t("validations.declaration.missing.pre_2024") - end + I18n.t("validations.declaration.missing.post_2024") end QUESTION_NUMBER_FROM_YEAR = { 2023 => 30, 2024 => 11, 2025 => 11, 2026 => 11 }.freeze diff --git a/app/models/form/lettings/questions/ethnic_white.rb b/app/models/form/lettings/questions/ethnic_white.rb index 98ebe78f3..4efaee83c 100644 --- a/app/models/form/lettings/questions/ethnic_white.rb +++ b/app/models/form/lettings/questions/ethnic_white.rb @@ -9,22 +9,13 @@ class Form::Lettings::Questions::EthnicWhite < ::Form::Question end def answer_options - if form.start_year_2024_or_later? - { - "1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" }, - "2" => { "value" => "Irish" }, - "18" => { "value" => "Gypsy or Irish Traveller" }, - "20" => { "value" => "Roma" }, - "3" => { "value" => "Any other White background" }, - }.freeze - else - { - "1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" }, - "2" => { "value" => "Irish" }, - "18" => { "value" => "Gypsy or Irish Traveller" }, - "3" => { "value" => "Any other White background" }, - }.freeze - end + { + "1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" }, + "2" => { "value" => "Irish" }, + "18" => { "value" => "Gypsy or Irish Traveller" }, + "20" => { "value" => "Roma" }, + "3" => { "value" => "Any other White background" }, + }.freeze end QUESTION_NUMBER_FROM_YEAR = { 2023 => 35, 2024 => 34, 2025 => 34, 2026 => 34 }.freeze diff --git a/app/models/form/lettings/questions/first_time_property_let_as_social_housing.rb b/app/models/form/lettings/questions/first_time_property_let_as_social_housing.rb index c9fb77abf..c120fbc24 100644 --- a/app/models/form/lettings/questions/first_time_property_let_as_social_housing.rb +++ b/app/models/form/lettings/questions/first_time_property_let_as_social_housing.rb @@ -14,11 +14,11 @@ class Form::Lettings::Questions::FirstTimePropertyLetAsSocialHousing < ::Form::Q end def yes_hint - form.start_year_2024_or_later? ? "This property was previously used for other purposes or is a new-build." : "This is a new let." + "This property was previously used for other purposes or is a new-build." end def no_hint - form.start_year_2024_or_later? ? "This is a re-let of existing social housing stock." : "This is a re-let of existing social housing." + "This is a re-let of existing social housing stock." end QUESTION_NUMBER_FROM_YEAR = { 2023 => 14, 2024 => 15, 2025 => 12, 2026 => 12 }.freeze diff --git a/app/models/form/lettings/questions/housingneeds_other.rb b/app/models/form/lettings/questions/housingneeds_other.rb index d8915e936..4be1ba6e0 100644 --- a/app/models/form/lettings/questions/housingneeds_other.rb +++ b/app/models/form/lettings/questions/housingneeds_other.rb @@ -9,19 +9,12 @@ class Form::Lettings::Questions::HousingneedsOther < ::Form::Question end def answer_options - if form.start_year_2024_or_later? - { - "1" => { "value" => "Yes" }, - "0" => { "value" => "No" }, - "divider" => { "value" => true }, - "2" => { "value" => "Don’t know" }, - }.freeze - else - { - "1" => { "value" => "Yes" }, - "0" => { "value" => "No" }, - }.freeze - end + { + "1" => { "value" => "Yes" }, + "0" => { "value" => "No" }, + "divider" => { "value" => true }, + "2" => { "value" => "Don’t know" }, + }.freeze end QUESTION_NUMBER_FROM_YEAR = { 2023 => 72, 2024 => 71, 2025 => 71, 2026 => 78 }.freeze diff --git a/app/models/form/lettings/questions/is_carehome.rb b/app/models/form/lettings/questions/is_carehome.rb index ea2df6eac..f66e1d939 100644 --- a/app/models/form/lettings/questions/is_carehome.rb +++ b/app/models/form/lettings/questions/is_carehome.rb @@ -10,17 +10,10 @@ class Form::Lettings::Questions::IsCarehome < ::Form::Question end def answer_options - if form.start_year_2024_or_later? - { - "1" => { "value" => "Yes" }, - "0" => { "value" => "No" }, - }.freeze - else - { - "0" => { "value" => "No" }, - "1" => { "value" => "Yes" }, - }.freeze - end + { + "1" => { "value" => "Yes" }, + "0" => { "value" => "No" }, + }.freeze end QUESTION_NUMBER_FROM_YEAR = { 2023 => 93, 2024 => 92, 2025 => 92, 2026 => 100 }.freeze diff --git a/app/models/form/lettings/questions/layear.rb b/app/models/form/lettings/questions/layear.rb index 2ae03212d..3b3493f69 100644 --- a/app/models/form/lettings/questions/layear.rb +++ b/app/models/form/lettings/questions/layear.rb @@ -21,7 +21,7 @@ class Form::Lettings::Questions::Layear < ::Form::Question "divider" => { "value" => true }, "6" => { "value" => "Don’t know" }, } - elsif form.start_year_2024_or_later? + else { "1" => { "value" => "Just moved to local authority area with this new let" }, "2" => { "value" => "Less than 1 year" }, @@ -34,18 +34,6 @@ class Form::Lettings::Questions::Layear < ::Form::Question "divider" => { "value" => true }, "6" => { "value" => "Don’t know" }, } - else - { - "1" => { "value" => "Just moved to local authority area" }, - "2" => { "value" => "Less than 1 year" }, - "7" => { "value" => "1 year but under 2 years" }, - "8" => { "value" => "2 years but under 3 years" }, - "9" => { "value" => "3 years but under 4 years" }, - "10" => { "value" => "4 years but under 5 years" }, - "5" => { "value" => "5 years or more" }, - "divider" => { "value" => true }, - "6" => { "value" => "Don’t know" }, - } end end diff --git a/app/models/form/lettings/questions/letting_allocation.rb b/app/models/form/lettings/questions/letting_allocation.rb index 2029335c4..ced1fb39b 100644 --- a/app/models/form/lettings/questions/letting_allocation.rb +++ b/app/models/form/lettings/questions/letting_allocation.rb @@ -8,24 +8,14 @@ class Form::Lettings::Questions::LettingAllocation < ::Form::Question end def answer_options - if form.start_year_2024_or_later? - { - "cbl" => { "value" => "Choice-based lettings (CBL)", "hint" => "Where available vacant properties are advertised and applicants are able to bid for specific properties." }, - "cap" => { "value" => "Common Allocation Policy (CAP)", "hint" => "Where a common system agreed between a group of housing providers is used to determine applicant’s priority for housing." }, - "chr" => { "value" => "Common housing register (CHR)", "hint" => "Where a single waiting list is used by a group of housing providers to receive and process housing applications. Providers may use different approaches to determine priority." }, - "accessible_register" => { "value" => "Accessible housing register", "hint" => "Where the ‘access category’ or another descriptor of whether an available vacant property meets a range of access needs is displayed to applicants during the allocations process." }, - "divider" => { "value" => true }, - "letting_allocation_unknown" => { "value" => "None of these allocation systems" }, - }.freeze - else - { - "cbl" => { "value" => "Choice-based lettings (CBL)" }, - "cap" => { "value" => "Common Allocation Policy (CAP)" }, - "chr" => { "value" => "Common housing register (CHR)" }, - "divider" => { "value" => true }, - "letting_allocation_unknown" => { "value" => "None of these allocation systems" }, - }.freeze - end + { + "cbl" => { "value" => "Choice-based lettings (CBL)", "hint" => "Where available vacant properties are advertised and applicants are able to bid for specific properties." }, + "cap" => { "value" => "Common Allocation Policy (CAP)", "hint" => "Where a common system agreed between a group of housing providers is used to determine applicant’s priority for housing." }, + "chr" => { "value" => "Common housing register (CHR)", "hint" => "Where a single waiting list is used by a group of housing providers to receive and process housing applications. Providers may use different approaches to determine priority." }, + "accessible_register" => { "value" => "Accessible housing register", "hint" => "Where the ‘access category’ or another descriptor of whether an available vacant property meets a range of access needs is displayed to applicants during the allocations process." }, + "divider" => { "value" => true }, + "letting_allocation_unknown" => { "value" => "None of these allocation systems" }, + }.freeze end QUESTION_NUMBER_FROM_YEAR = { 2023 => 84, 2024 => 83, 2025 => 83, 2026 => 90 }.freeze diff --git a/app/models/form/lettings/questions/nationality.rb b/app/models/form/lettings/questions/nationality.rb deleted file mode 100644 index a966f68f7..000000000 --- a/app/models/form/lettings/questions/nationality.rb +++ /dev/null @@ -1,23 +0,0 @@ -class Form::Lettings::Questions::Nationality < ::Form::Question - def initialize(id, hsh, page) - super - @id = "national" - @type = "radio" - @check_answers_card_number = 1 - @answer_options = ANSWER_OPTIONS - @question_number = get_question_number_from_hash(QUESTION_NUMBER_FROM_YEAR) - end - - ANSWER_OPTIONS = { - "18" => { "value" => "United Kingdom" }, - "17" => { "value" => "Republic of Ireland" }, - "19" => { "value" => "European Economic Area (EEA) country, excluding Ireland" }, - "20" => { "value" => "Afghanistan" }, - "21" => { "value" => "Ukraine" }, - "12" => { "value" => "Other" }, - "divider" => true, - "13" => { "value" => "Tenant prefers not to say" }, - }.freeze - - QUESTION_NUMBER_FROM_YEAR = { 2023 => 36, 2024 => 35, 2025 => 35, 2026 => 34 }.freeze -end diff --git a/app/models/form/lettings/questions/person_relationship.rb b/app/models/form/lettings/questions/person_relationship.rb index d39cb49ff..8da3e4f5a 100644 --- a/app/models/form/lettings/questions/person_relationship.rb +++ b/app/models/form/lettings/questions/person_relationship.rb @@ -10,26 +10,13 @@ class Form::Lettings::Questions::PersonRelationship < ::Form::Question end def answer_options - if form.start_year_2024_or_later? - { - "P" => { "value" => "Partner" }, - "C" => { "value" => "Child" }, - "X" => { "value" => "Other" }, - "divider" => { "value" => true }, - "R" => { "value" => "Person prefers not to say" }, - } - else - { - "P" => { "value" => "Partner" }, - "C" => { - "value" => "Child", - "hint" => "Must be eligible for child benefit: under age 16 or under 20 if still in full-time education.", - }, - "X" => { "value" => "Other" }, - "divider" => { "value" => true }, - "R" => { "value" => "Person prefers not to say" }, - } - end + { + "P" => { "value" => "Partner" }, + "C" => { "value" => "Child" }, + "X" => { "value" => "Other" }, + "divider" => { "value" => true }, + "R" => { "value" => "Person prefers not to say" }, + } end def question_number diff --git a/app/models/form/lettings/questions/previous_let_type.rb b/app/models/form/lettings/questions/previous_let_type.rb index 660e42869..6058b9a17 100644 --- a/app/models/form/lettings/questions/previous_let_type.rb +++ b/app/models/form/lettings/questions/previous_let_type.rb @@ -8,17 +8,6 @@ class Form::Lettings::Questions::PreviousLetType < ::Form::Question end ANSWER_OPTIONS = { - "1" => { "value" => "Social rent basis" }, - "2" => { "value" => "Affordable rent basis" }, - "5" => { "value" => "A London Affordable Rent basis" }, - "6" => { "value" => "A Rent to Buy basis" }, - "7" => { "value" => "A London Living Rent basis" }, - "8" => { "value" => "Another Intermediate Rent basis" }, - "divider" => { "value" => true }, - "3" => { "value" => "Don’t know" }, - }.freeze - - ANSWER_OPTIONS_AFTER_2024 = { "1" => { "value" => "Social rent basis" }, "2" => { "value" => "Affordable rent basis" }, "5" => { "value" => "London Affordable Rent basis" }, @@ -45,7 +34,6 @@ class Form::Lettings::Questions::PreviousLetType < ::Form::Question def answer_options return ANSWER_OPTIONS_AFTER_2025 if form.start_year_2025_or_later? - return ANSWER_OPTIONS_AFTER_2024 if form.start_year_2024_or_later? ANSWER_OPTIONS end diff --git a/app/models/form/lettings/questions/reason_renewal.rb b/app/models/form/lettings/questions/reason_renewal.rb index d5fccca67..ee33e6401 100644 --- a/app/models/form/lettings/questions/reason_renewal.rb +++ b/app/models/form/lettings/questions/reason_renewal.rb @@ -14,27 +14,16 @@ class Form::Lettings::Questions::ReasonRenewal < ::Form::Question end def answer_options - if form.start_year_2024_or_later? - { - "50" => { "value" => "End of social or private sector tenancy - no fault" }, - "51" => { "value" => "End of social or private sector tenancy - evicted due to anti-social behaviour (ASB)" }, - "52" => { "value" => "End of social or private sector tenancy - evicted due to rent arrears" }, - "53" => { "value" => "End of social or private sector tenancy - evicted for any other reason" }, - "20" => { "value" => "Other" }, - "47" => { "value" => "Tenant prefers not to say" }, - "divider" => { "value" => true }, - "28" => { "value" => "Don’t know" }, - }.freeze - else - { - "40" => { "value" => "End of assured shorthold tenancy (no fault)" }, - "42" => { "value" => "End of fixed term tenancy (no fault)" }, - "20" => { "value" => "Other" }, - "47" => { "value" => "Tenant prefers not to say" }, - "divider" => { "value" => true }, - "28" => { "value" => "Don’t know" }, - }.freeze - end + { + "50" => { "value" => "End of social or private sector tenancy - no fault" }, + "51" => { "value" => "End of social or private sector tenancy - evicted due to anti-social behaviour (ASB)" }, + "52" => { "value" => "End of social or private sector tenancy - evicted due to rent arrears" }, + "53" => { "value" => "End of social or private sector tenancy - evicted for any other reason" }, + "20" => { "value" => "Other" }, + "47" => { "value" => "Tenant prefers not to say" }, + "divider" => { "value" => true }, + "28" => { "value" => "Don’t know" }, + }.freeze end QUESTION_NUMBER_FROM_YEAR = { 2023 => 77, 2024 => 76, 2025 => 76, 2026 => 83 }.freeze diff --git a/app/models/form/lettings/questions/referral_general_needs_prp.rb b/app/models/form/lettings/questions/referral_general_needs_prp.rb index 37d222961..091d842e9 100644 --- a/app/models/form/lettings/questions/referral_general_needs_prp.rb +++ b/app/models/form/lettings/questions/referral_general_needs_prp.rb @@ -10,96 +10,48 @@ class Form::Lettings::Questions::ReferralGeneralNeedsPrp < ::Form::Question end def answer_options - if form.start_year_2024_or_later? - { - "1" => { - "value" => "Internal transfer", - "hint" => "Where the tenant has moved to another social property owned by the same landlord.", - }, - "2" => { - "value" => "Tenant applied directly (no referral or nomination)", - }, - "3" => { - "value" => "Nominated by a local housing authority", - }, - "8" => { - "value" => "Re-located through official housing mobility scheme", - }, - "10" => { - "value" => "Other social landlord", - }, - "9" => { - "value" => "Community learning disability team", - }, - "14" => { - "value" => "Community mental health team", - }, - "15" => { - "value" => "Health service", - }, - "18" => { - "value" => "Police, probation, prison or youth offending team – tenant had custodial sentence", - }, - "19" => { - "value" => "Police, probation, prison or youth offending team – no custodial sentence", - }, - "7" => { - "value" => "Voluntary agency", - }, - "17" => { - "value" => "Children’s Social Care", - }, - "16" => { - "value" => "Other", - }, - }.freeze - else - { - "1" => { - "value" => "Internal transfer", - "hint" => "Where the tenant has moved to another social property owned by the same landlord.", - }, - "2" => { - "value" => "Tenant applied directly (no referral or nomination)", - }, - "3" => { - "value" => "Nominated by a local housing authority", - }, - "4" => { - "value" => "Referred by local authority housing department", - }, - "8" => { - "value" => "Re-located through official housing mobility scheme", - }, - "10" => { - "value" => "Other social landlord", - }, - "9" => { - "value" => "Community learning disability team", - }, - "14" => { - "value" => "Community mental health team", - }, - "15" => { - "value" => "Health service", - }, - "12" => { - "value" => "Police, probation or prison", - }, - "7" => { - "value" => "Voluntary agency", - }, - "13" => { - "value" => "Youth offending team", - }, - "17" => { - "value" => "Children’s Social Care", - }, - "16" => { - "value" => "Other", - }, - }.freeze - end + { + "1" => { + "value" => "Internal transfer", + "hint" => "Where the tenant has moved to another social property owned by the same landlord.", + }, + "2" => { + "value" => "Tenant applied directly (no referral or nomination)", + }, + "3" => { + "value" => "Nominated by a local housing authority", + }, + "8" => { + "value" => "Re-located through official housing mobility scheme", + }, + "10" => { + "value" => "Other social landlord", + }, + "9" => { + "value" => "Community learning disability team", + }, + "14" => { + "value" => "Community mental health team", + }, + "15" => { + "value" => "Health service", + }, + "18" => { + "value" => "Police, probation, prison or youth offending team – tenant had custodial sentence", + }, + "19" => { + "value" => "Police, probation, prison or youth offending team – no custodial sentence", + }, + "7" => { + "value" => "Voluntary agency", + }, + "17" => { + "value" => "Children’s Social Care", + }, + "16" => { + "value" => "Other", + }, + }.freeze end QUESTION_NUMBER_FROM_YEAR = { 2023 => 85, 2024 => 84, 2025 => 84 }.freeze diff --git a/app/models/form/sales/pages/uprn.rb b/app/models/form/sales/pages/uprn.rb index a78b87c2f..67e0589a1 100644 --- a/app/models/form/sales/pages/uprn.rb +++ b/app/models/form/sales/pages/uprn.rb @@ -13,20 +13,12 @@ class Form::Sales::Pages::Uprn < ::Form::Page end def skip_text - if form.start_year_2024_or_later? - "Search for address instead" - else - "Enter address instead" - end + "Search for address instead" end def skip_href(log = nil) return unless log - if form.start_year_2024_or_later? - "address-matcher" - else - "address" - end + "address-matcher" end end diff --git a/app/models/sales_log.rb b/app/models/sales_log.rb index 06f1c201b..02a9b67bf 100644 --- a/app/models/sales_log.rb +++ b/app/models/sales_log.rb @@ -142,7 +142,7 @@ class SalesLog < Log def dynamically_not_required not_required = [] - not_required << "deposit" if form.start_year_2024_or_later? && stairowned_100? + not_required << "deposit" if stairowned_100? not_required += %w[address_line2 county] not_required @@ -473,7 +473,6 @@ class SalesLog < Log def should_process_address_change? return unless uprn_selection || select_best_address_match return unless saledate - return unless form.start_year_2024_or_later? return if skip_address_lookup if select_best_address_match @@ -552,10 +551,6 @@ class SalesLog < Log form.start_year_2026_or_later? ? "sexrab1" : "sex1"].compact end - def soctenant_is_inferred? - form.start_year_2024_or_later? - end - def duplicates return SalesLog.none if duplicate_set_id.nil? diff --git a/spec/models/form/lettings/questions/declaration_spec.rb b/spec/models/form/lettings/questions/declaration_spec.rb index 25705414c..30437847a 100644 --- a/spec/models/form/lettings/questions/declaration_spec.rb +++ b/spec/models/form/lettings/questions/declaration_spec.rb @@ -1,16 +1,17 @@ require "rails_helper" RSpec.describe Form::Lettings::Questions::Declaration, type: :model do + include CollectionTimeHelper + subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } let(:question_definition) { nil } let(:page) { instance_double(Form::Page) } let(:subsection) { instance_double(Form::Subsection) } - let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } + let(:form) { instance_double(Form, start_date: current_collection_start_date) } before do - allow(form).to receive(:start_year_2024_or_later?) allow(page).to receive(:subsection).and_return(subsection) allow(subsection).to receive(:form).and_return(form) end @@ -31,51 +32,21 @@ RSpec.describe Form::Lettings::Questions::Declaration, type: :model do expect(question.derived?(nil)).to be false end - context "when the form year is before 2024" do - before do - allow(form).to receive(:start_year_2024_or_later?).and_return(false) - end - - it "has the correct answer_options" do - expect(question.answer_options).to eq({ - "declaration" => { "value" => "The tenant has seen the MHCLG privacy notice" }, - }) - end - - it "uses the expected top guidance partial" do - expect(question.top_guidance_partial).to eq("privacy_notice_tenant") - end - - it "has check_answers_card_number = 0" do - expect(question.check_answers_card_number).to eq(0) - end - - it "returns correct unanswered_error_message" do - expect(question.unanswered_error_message).to eq("You must show the MHCLG privacy notice to the tenant before you can submit this log.") - end + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "declaration" => { "value" => "The tenant has seen or been given access to the MHCLG privacy notice" }, + }) end - context "when the form year is >= 2024" do - before do - allow(form).to receive(:start_year_2024_or_later?).and_return(true) - end - - it "has the correct answer_options" do - expect(question.answer_options).to eq({ - "declaration" => { "value" => "The tenant has seen or been given access to the MHCLG privacy notice" }, - }) - end - - it "uses the expected top guidance partial" do - expect(question.top_guidance_partial).to eq("privacy_notice_tenant") - end + it "uses the expected top guidance partial" do + expect(question.top_guidance_partial).to eq("privacy_notice_tenant") + end - it "has check_answers_card_number nil" do - expect(question.check_answers_card_number).to be_nil - end + it "has check_answers_card_number nil" do + expect(question.check_answers_card_number).to be_nil + end - it "returns correct unanswered_error_message" do - expect(question.unanswered_error_message).to eq("You must show or give the tenant access to the MHCLG privacy notice before you can submit this log.") - end + it "returns correct unanswered_error_message" do + expect(question.unanswered_error_message).to eq("You must show or give the tenant access to the MHCLG privacy notice before you can submit this log.") end end diff --git a/spec/models/form/lettings/questions/ethnic_white_spec.rb b/spec/models/form/lettings/questions/ethnic_white_spec.rb index ab20dd8ca..f913c1b40 100644 --- a/spec/models/form/lettings/questions/ethnic_white_spec.rb +++ b/spec/models/form/lettings/questions/ethnic_white_spec.rb @@ -1,16 +1,17 @@ require "rails_helper" RSpec.describe Form::Lettings::Questions::EthnicWhite, type: :model do + include CollectionTimeHelper + subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } let(:question_definition) { nil } let(:page) { instance_double(Form::Page) } let(:subsection) { instance_double(Form::Subsection) } - let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } + let(:form) { instance_double(Form, start_date: current_collection_start_date) } before do - allow(form).to receive(:start_year_2024_or_later?).and_return(false) allow(page).to receive(:subsection).and_return(subsection) allow(subsection).to receive(:form).and_return(form) end @@ -31,31 +32,14 @@ RSpec.describe Form::Lettings::Questions::EthnicWhite, type: :model do expect(question.derived?(nil)).to be false end - context "with 2023/24 form" do - it "has the correct answer_options" do - expect(question.answer_options).to eq({ - "1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" }, - "2" => { "value" => "Irish" }, - "18" => { "value" => "Gypsy or Irish Traveller" }, - "3" => { "value" => "Any other White background" }, - }) - end - end - - context "with 2024/25 form" do - before do - allow(form).to receive(:start_year_2024_or_later?).and_return(true) - end - - it "has the correct answer_options" do - expect(question.answer_options).to eq({ - "1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" }, - "2" => { "value" => "Irish" }, - "18" => { "value" => "Gypsy or Irish Traveller" }, - "20" => { "value" => "Roma" }, - "3" => { "value" => "Any other White background" }, - }) - end + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" }, + "2" => { "value" => "Irish" }, + "18" => { "value" => "Gypsy or Irish Traveller" }, + "20" => { "value" => "Roma" }, + "3" => { "value" => "Any other White background" }, + }) end it "has the correct check_answers_card_number" do diff --git a/spec/models/form/lettings/questions/first_time_property_let_as_social_housing_spec.rb b/spec/models/form/lettings/questions/first_time_property_let_as_social_housing_spec.rb index 552734991..82c9bb5cb 100644 --- a/spec/models/form/lettings/questions/first_time_property_let_as_social_housing_spec.rb +++ b/spec/models/form/lettings/questions/first_time_property_let_as_social_housing_spec.rb @@ -1,16 +1,17 @@ require "rails_helper" RSpec.describe Form::Lettings::Questions::FirstTimePropertyLetAsSocialHousing, type: :model do + include CollectionTimeHelper + subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } let(:question_definition) { nil } let(:page) { instance_double(Form::Page) } let(:subsection) { instance_double(Form::Subsection) } - let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } + let(:form) { instance_double(Form, start_date: current_collection_start_date) } before do - allow(form).to receive(:start_year_2024_or_later?).and_return(false) allow(page).to receive(:subsection).and_return(subsection) allow(subsection).to receive(:form).and_return(form) end @@ -23,29 +24,16 @@ RSpec.describe Form::Lettings::Questions::FirstTimePropertyLetAsSocialHousing, t expect(question.id).to eq("first_time_property_let_as_social_housing") end - context "with 2023/24 form" do - it "has the correct answer_options" do - expect(question.answer_options).to eq({ - "1" => { "value" => "Yes", "hint" => "This is a new let." }, - "0" => { "value" => "No", "hint" => "This is a re-let of existing social housing." }, - }) - end + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "1" => { "value" => "Yes", "hint" => "This property was previously used for other purposes or is a new-build." }, + "0" => { "value" => "No", "hint" => "This is a re-let of existing social housing stock." }, + }) end context "with 2024/25 form" do let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } - before do - allow(form).to receive(:start_year_2024_or_later?).and_return(true) - end - - it "has the correct answer_options" do - expect(question.answer_options).to eq({ - "1" => { "value" => "Yes", "hint" => "This property was previously used for other purposes or is a new-build." }, - "0" => { "value" => "No", "hint" => "This is a re-let of existing social housing stock." }, - }) - end - it "has the correct question number" do expect(question.question_number).to eq(15) end @@ -54,10 +42,6 @@ RSpec.describe Form::Lettings::Questions::FirstTimePropertyLetAsSocialHousing, t context "with 2025/26 form" do let(:form) { instance_double(Form, start_date: Time.zone.local(2025, 4, 1)) } - before do - allow(form).to receive(:start_year_2024_or_later?).and_return(true) - end - it "has the correct question number" do expect(question.question_number).to eq(12) end diff --git a/spec/models/form/lettings/questions/housingneeds_other_spec.rb b/spec/models/form/lettings/questions/housingneeds_other_spec.rb index fa16eda63..b1dac468e 100644 --- a/spec/models/form/lettings/questions/housingneeds_other_spec.rb +++ b/spec/models/form/lettings/questions/housingneeds_other_spec.rb @@ -1,16 +1,17 @@ require "rails_helper" RSpec.describe Form::Lettings::Questions::HousingneedsOther, type: :model do + include CollectionTimeHelper + subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } let(:question_definition) { nil } let(:page) { instance_double(Form::Page) } let(:subsection) { instance_double(Form::Subsection) } - let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } + let(:form) { instance_double(Form, start_date: current_collection_start_date) } before do - allow(form).to receive(:start_year_2024_or_later?).and_return(false) allow(page).to receive(:subsection).and_return(subsection) allow(subsection).to receive(:form).and_return(form) end @@ -31,28 +32,13 @@ RSpec.describe Form::Lettings::Questions::HousingneedsOther, type: :model do expect(question.derived?(nil)).to be false end - context "with 2023/24 form" do - it "has the correct answer_options" do - expect(question.answer_options).to eq({ - "1" => { "value" => "Yes" }, - "0" => { "value" => "No" }, - }) - end - end - - context "with 2024/25 form" do - before do - allow(form).to receive(:start_year_2024_or_later?).and_return(true) - end - - it "has the correct answer_options" do - expect(question.answer_options).to eq({ - "1" => { "value" => "Yes" }, - "0" => { "value" => "No" }, - "divider" => { "value" => true }, - "2" => { "value" => "Don’t know" }, - }) - end + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "1" => { "value" => "Yes" }, + "0" => { "value" => "No" }, + "divider" => { "value" => true }, + "2" => { "value" => "Don’t know" }, + }) end it "has the correct check_answers_card_number" do diff --git a/spec/models/form/lettings/questions/is_carehome_spec.rb b/spec/models/form/lettings/questions/is_carehome_spec.rb index b82ddeaeb..c7d587270 100644 --- a/spec/models/form/lettings/questions/is_carehome_spec.rb +++ b/spec/models/form/lettings/questions/is_carehome_spec.rb @@ -1,16 +1,17 @@ require "rails_helper" RSpec.describe Form::Lettings::Questions::IsCarehome, type: :model do + include CollectionTimeHelper + subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } let(:question_definition) { nil } let(:page) { instance_double(Form::Page) } let(:subsection) { instance_double(Form::Subsection) } - let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } + let(:form) { instance_double(Form, start_date: current_collection_start_date) } before do - allow(form).to receive(:start_year_2024_or_later?).and_return(false) allow(page).to receive(:subsection).and_return(subsection) allow(subsection).to receive(:form).and_return(form) end @@ -31,26 +32,11 @@ RSpec.describe Form::Lettings::Questions::IsCarehome, type: :model do expect(question.derived?(nil)).to be false end - context "with 2023/24 form" do - it "has the correct answer_options in the correct order" do - expect(question.answer_options.map { |k, v| [k, v["value"]] }).to eq([ - %w[0 No], - %w[1 Yes], - ]) - end - end - - context "with 2024/25 form" do - before do - allow(form).to receive(:start_year_2024_or_later?).and_return(true) - end - - it "has the correct answer_options in the correct order" do - expect(question.answer_options.map { |k, v| [k, v["value"]] }).to eq([ - %w[1 Yes], - %w[0 No], - ]) - end + it "has the correct answer_options in the correct order" do + expect(question.answer_options.map { |k, v| [k, v["value"]] }).to eq([ + %w[1 Yes], + %w[0 No], + ]) end it "has the correct check_answers_card_number" do diff --git a/spec/models/form/lettings/questions/layear_spec.rb b/spec/models/form/lettings/questions/layear_spec.rb index b7023c711..9c0d9a770 100644 --- a/spec/models/form/lettings/questions/layear_spec.rb +++ b/spec/models/form/lettings/questions/layear_spec.rb @@ -1,16 +1,17 @@ require "rails_helper" RSpec.describe Form::Lettings::Questions::Layear, type: :model do + include CollectionTimeHelper + subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } let(:question_definition) { nil } let(:page) { instance_double(Form::Page) } let(:subsection) { instance_double(Form::Subsection) } - let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } + let(:form) { instance_double(Form, start_date: current_collection_start_date) } before do - allow(form).to receive_messages(start_year_2024_or_later?: false, start_year_2025_or_later?: false) allow(page).to receive(:subsection).and_return(subsection) allow(subsection).to receive(:form).and_return(form) end @@ -31,25 +32,9 @@ RSpec.describe Form::Lettings::Questions::Layear, type: :model do expect(question.derived?(nil)).to be false end - context "with 2023/24 form" do - it "has the correct answer_options" do - expect(question.answer_options).to eq({ - "1" => { "value" => "Just moved to local authority area" }, - "2" => { "value" => "Less than 1 year" }, - "7" => { "value" => "1 year but under 2 years" }, - "8" => { "value" => "2 years but under 3 years" }, - "9" => { "value" => "3 years but under 4 years" }, - "10" => { "value" => "4 years but under 5 years" }, - "5" => { "value" => "5 years or more" }, - "divider" => { "value" => true }, - "6" => { "value" => "Don’t know" }, - }) - end - end - context "with 2024/25 form" 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 the correct answer_options" do diff --git a/spec/models/form/lettings/questions/letting_allocation_spec.rb b/spec/models/form/lettings/questions/letting_allocation_spec.rb index 980c8fea5..660b6e909 100644 --- a/spec/models/form/lettings/questions/letting_allocation_spec.rb +++ b/spec/models/form/lettings/questions/letting_allocation_spec.rb @@ -1,16 +1,17 @@ require "rails_helper" RSpec.describe Form::Lettings::Questions::LettingAllocation, type: :model do + include CollectionTimeHelper + subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } let(:question_definition) { nil } let(:page) { instance_double(Form::Page) } let(:subsection) { instance_double(Form::Subsection) } - let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } + let(:form) { instance_double(Form, start_date: current_collection_start_date) } before do - allow(form).to receive(:start_year_2024_or_later?).and_return(false) allow(page).to receive(:subsection).and_return(subsection) allow(subsection).to receive(:form).and_return(form) end @@ -31,33 +32,15 @@ RSpec.describe Form::Lettings::Questions::LettingAllocation, type: :model do expect(question.derived?(nil)).to be false end - context "with 2023/24 form" do - it "has the correct answer_options" do - expect(question.answer_options).to eq({ - "cbl" => { "value" => "Choice-based lettings (CBL)" }, - "cap" => { "value" => "Common Allocation Policy (CAP)" }, - "chr" => { "value" => "Common housing register (CHR)" }, - "divider" => { "value" => true }, - "letting_allocation_unknown" => { "value" => "None of these allocation systems" }, - }) - end - end - - context "with 2024/25 form" do - before do - allow(form).to receive(:start_year_2024_or_later?).and_return(true) - end - - it "has the correct answer_options" do - expect(question.answer_options).to eq({ - "cbl" => { "value" => "Choice-based lettings (CBL)", "hint" => "Where available vacant properties are advertised and applicants are able to bid for specific properties." }, - "cap" => { "value" => "Common Allocation Policy (CAP)", "hint" => "Where a common system agreed between a group of housing providers is used to determine applicant’s priority for housing." }, - "chr" => { "value" => "Common housing register (CHR)", "hint" => "Where a single waiting list is used by a group of housing providers to receive and process housing applications. Providers may use different approaches to determine priority." }, - "accessible_register" => { "value" => "Accessible housing register", "hint" => "Where the ‘access category’ or another descriptor of whether an available vacant property meets a range of access needs is displayed to applicants during the allocations process." }, - "divider" => { "value" => true }, - "letting_allocation_unknown" => { "value" => "None of these allocation systems" }, - }) - end + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "cbl" => { "value" => "Choice-based lettings (CBL)", "hint" => "Where available vacant properties are advertised and applicants are able to bid for specific properties." }, + "cap" => { "value" => "Common Allocation Policy (CAP)", "hint" => "Where a common system agreed between a group of housing providers is used to determine applicant’s priority for housing." }, + "chr" => { "value" => "Common housing register (CHR)", "hint" => "Where a single waiting list is used by a group of housing providers to receive and process housing applications. Providers may use different approaches to determine priority." }, + "accessible_register" => { "value" => "Accessible housing register", "hint" => "Where the ‘access category’ or another descriptor of whether an available vacant property meets a range of access needs is displayed to applicants during the allocations process." }, + "divider" => { "value" => true }, + "letting_allocation_unknown" => { "value" => "None of these allocation systems" }, + }) end it "has the correct check_answers_card_number" do diff --git a/spec/models/form/lettings/questions/nationality_spec.rb b/spec/models/form/lettings/questions/nationality_spec.rb deleted file mode 100644 index 5bdebc57e..000000000 --- a/spec/models/form/lettings/questions/nationality_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require "rails_helper" - -RSpec.describe Form::Lettings::Questions::Nationality, type: :model do - subject(:question) { described_class.new(nil, nil, page) } - - let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)))) } - - it "has correct page" do - expect(question.page).to eq(page) - end - - it "has the correct id" do - expect(question.id).to eq("national") - end - - it "has the correct type" do - expect(question.type).to eq("radio") - end - - it "has the correct answer_options" do - expect(question.answer_options).to eq({ - "18" => { "value" => "United Kingdom" }, - "17" => { "value" => "Republic of Ireland" }, - "19" => { "value" => "European Economic Area (EEA) country, excluding Ireland" }, - "20" => { "value" => "Afghanistan" }, - "21" => { "value" => "Ukraine" }, - "12" => { "value" => "Other" }, - "divider" => true, - "13" => { "value" => "Tenant prefers not to say" }, - }) - end - - it "is not marked as derived" do - expect(question.derived?(nil)).to be false - end -end diff --git a/spec/models/form/lettings/questions/person_relationship_spec.rb b/spec/models/form/lettings/questions/person_relationship_spec.rb index 30073d347..1ae5f8135 100644 --- a/spec/models/form/lettings/questions/person_relationship_spec.rb +++ b/spec/models/form/lettings/questions/person_relationship_spec.rb @@ -1,10 +1,12 @@ require "rails_helper" RSpec.describe Form::Lettings::Questions::PersonRelationship, type: :model do + include CollectionTimeHelper + subject(:question) { described_class.new(nil, question_definition, page, person_index:) } 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, 4), start_year_2024_or_later?: false))) } + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: current_collection_start_date))) } let(:person_index) { 2 } it "has correct page" do @@ -20,7 +22,7 @@ RSpec.describe Form::Lettings::Questions::PersonRelationship, type: :model do end it "has the correct answer_options" do - expect(question.answer_options).to eq("C" => { "hint" => "Must be eligible for child benefit: under age 16 or under 20 if still in full-time education.", "value" => "Child" }, + expect(question.answer_options).to eq("C" => { "value" => "Child" }, "P" => { "value" => "Partner" }, "R" => { "value" => "Person prefers not to say" }, "X" => { "value" => "Other" }, diff --git a/spec/models/form/lettings/questions/previous_let_type_spec.rb b/spec/models/form/lettings/questions/previous_let_type_spec.rb index 64f5f5804..078a1a036 100644 --- a/spec/models/form/lettings/questions/previous_let_type_spec.rb +++ b/spec/models/form/lettings/questions/previous_let_type_spec.rb @@ -1,14 +1,15 @@ require "rails_helper" RSpec.describe Form::Lettings::Questions::PreviousLetType, type: :model do + include CollectionTimeHelper + subject(:question) { described_class.new(nil, nil, page) } let(:page) { instance_double(Form::Page) } let(:subsection) { instance_double(Form::Subsection) } - let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } + let(:form) { instance_double(Form, start_date: current_collection_start_date, start_year_2025_or_later?: true) } before do - allow(form).to receive_messages(start_year_2024_or_later?: false, start_year_2025_or_later?: false) allow(page).to receive(:subsection).and_return(subsection) allow(subsection).to receive(:form).and_return(form) end @@ -29,25 +30,8 @@ RSpec.describe Form::Lettings::Questions::PreviousLetType, type: :model do expect(question.derived?(nil)).to be false end - it "has the correct answer options" do - expect(question.answer_options).to eq({ - "1" => { "value" => "Social rent basis" }, - "2" => { "value" => "Affordable rent basis" }, - "5" => { "value" => "A London Affordable Rent basis" }, - "6" => { "value" => "A Rent to Buy basis" }, - "7" => { "value" => "A London Living Rent basis" }, - "8" => { "value" => "Another Intermediate Rent basis" }, - "divider" => { "value" => true }, - "3" => { "value" => "Don’t know" }, - }) - end - - context "with collection year on or after 2024" do - let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } - - before do - allow(form).to receive(:start_year_2024_or_later?).and_return(true) - end + context "with 2024/25 form" do + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1), start_year_2025_or_later?: false) } it "has the correct answer options" do expect(question.answer_options).to eq({ @@ -68,11 +52,7 @@ RSpec.describe Form::Lettings::Questions::PreviousLetType, type: :model do end context "with collection year on or after 2025" do - let(:form) { instance_double(Form, start_date: Time.zone.local(2025, 4, 1)) } - - before do - allow(form).to receive(:start_year_2025_or_later?).and_return(true) - end + let(:form) { instance_double(Form, start_date: Time.zone.local(2025, 4, 1), start_year_2025_or_later?: true) } it "has the correct answer options" do expect(question.answer_options).to eq({ diff --git a/spec/models/form/lettings/questions/reason_renewal_spec.rb b/spec/models/form/lettings/questions/reason_renewal_spec.rb index e58a33a21..7a686ae45 100644 --- a/spec/models/form/lettings/questions/reason_renewal_spec.rb +++ b/spec/models/form/lettings/questions/reason_renewal_spec.rb @@ -1,16 +1,17 @@ require "rails_helper" RSpec.describe Form::Lettings::Questions::ReasonRenewal, type: :model do + include CollectionTimeHelper + subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } let(:question_definition) { nil } let(:page) { instance_double(Form::Page, id: "reason_renewal") } let(:subsection) { instance_double(Form::Subsection) } - let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } + let(:form) { instance_double(Form, start_date: current_collection_start_date) } before do - allow(form).to receive(:start_year_2024_or_later?).and_return(false) allow(page).to receive(:subsection).and_return(subsection) allow(subsection).to receive(:form).and_return(form) end @@ -39,35 +40,16 @@ RSpec.describe Form::Lettings::Questions::ReasonRenewal, type: :model do expect(question).not_to be_derived(nil) end - context "with 2023/24 form" do - it "has the correct answer_options" do - expect(question.answer_options).to eq({ - "40" => { "value" => "End of assured shorthold tenancy (no fault)" }, - "42" => { "value" => "End of fixed term tenancy (no fault)" }, - "20" => { "value" => "Other" }, - "47" => { "value" => "Tenant prefers not to say" }, - "divider" => { "value" => true }, - "28" => { "value" => "Don’t know" }, - }) - end - end - - context "with 2024/25 form" do - before do - allow(form).to receive(:start_year_2024_or_later?).and_return(true) - end - - it "has the correct answer_options" do - expect(question.answer_options).to eq({ - "50" => { "value" => "End of social or private sector tenancy - no fault" }, - "51" => { "value" => "End of social or private sector tenancy - evicted due to anti-social behaviour (ASB)" }, - "52" => { "value" => "End of social or private sector tenancy - evicted due to rent arrears" }, - "53" => { "value" => "End of social or private sector tenancy - evicted for any other reason" }, - "20" => { "value" => "Other" }, - "47" => { "value" => "Tenant prefers not to say" }, - "divider" => { "value" => true }, - "28" => { "value" => "Don’t know" }, - }) - end + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "50" => { "value" => "End of social or private sector tenancy - no fault" }, + "51" => { "value" => "End of social or private sector tenancy - evicted due to anti-social behaviour (ASB)" }, + "52" => { "value" => "End of social or private sector tenancy - evicted due to rent arrears" }, + "53" => { "value" => "End of social or private sector tenancy - evicted for any other reason" }, + "20" => { "value" => "Other" }, + "47" => { "value" => "Tenant prefers not to say" }, + "divider" => { "value" => true }, + "28" => { "value" => "Don’t know" }, + }) end end diff --git a/spec/models/form/lettings/questions/referral_general_needs_prp_spec.rb b/spec/models/form/lettings/questions/referral_general_needs_prp_spec.rb index 832394bcc..6cb2d447f 100644 --- a/spec/models/form/lettings/questions/referral_general_needs_prp_spec.rb +++ b/spec/models/form/lettings/questions/referral_general_needs_prp_spec.rb @@ -1,16 +1,17 @@ require "rails_helper" RSpec.describe Form::Lettings::Questions::ReferralGeneralNeedsPrp, type: :model do + include CollectionTimeHelper + subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } let(:question_definition) { nil } let(:page) { instance_double(Form::Page) } let(:subsection) { instance_double(Form::Subsection) } - let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } + let(:form) { instance_double(Form, start_date: current_collection_start_date) } before do - allow(form).to receive(:start_year_2024_or_later?).and_return(false) allow(page).to receive(:subsection).and_return(subsection) allow(subsection).to receive(:form).and_return(form) end @@ -35,58 +36,25 @@ RSpec.describe Form::Lettings::Questions::ReferralGeneralNeedsPrp, type: :model expect(question).not_to be_derived(nil) end - context "with 2023/24 form" do - it "has the correct answer_options" do - expect(question.answer_options).to eq({ - "1" => { "value" => "Internal transfer", "hint" => "Where the tenant has moved to another social property owned by the same landlord." }, - "2" => { "value" => "Tenant applied directly (no referral or nomination)" }, - "3" => { "value" => "Nominated by a local housing authority" }, - "4" => { "value" => "Referred by local authority housing department" }, - "8" => { "value" => "Re-located through official housing mobility scheme" }, - "10" => { "value" => "Other social landlord" }, - "9" => { "value" => "Community learning disability team" }, - "14" => { "value" => "Community mental health team" }, - "15" => { "value" => "Health service" }, - "12" => { "value" => "Police, probation or prison" }, - "7" => { "value" => "Voluntary agency" }, - "13" => { "value" => "Youth offending team" }, - "17" => { "value" => "Children’s Social Care" }, - "16" => { "value" => "Other" }, - }) - end - - it "has the correct question number" do - expect(question.question_number).to eq(85) - end - end - - context "with 2024/25 form" do - let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } - - before do - allow(form).to receive(:start_year_2024_or_later?).and_return(true) - end - - it "has the correct answer_options" do - expect(question.answer_options).to eq({ - "1" => { "value" => "Internal transfer", "hint" => "Where the tenant has moved to another social property owned by the same landlord." }, - "2" => { "value" => "Tenant applied directly (no referral or nomination)" }, - "3" => { "value" => "Nominated by a local housing authority" }, - "8" => { "value" => "Re-located through official housing mobility scheme" }, - "10" => { "value" => "Other social landlord" }, - "9" => { "value" => "Community learning disability team" }, - "14" => { "value" => "Community mental health team" }, - "15" => { "value" => "Health service" }, - "18" => { "value" => "Police, probation, prison or youth offending team – tenant had custodial sentence" }, - "19" => { "value" => "Police, probation, prison or youth offending team – no custodial sentence" }, - "7" => { "value" => "Voluntary agency" }, - "17" => { "value" => "Children’s Social Care" }, - "16" => { "value" => "Other" }, - }) - end - - it "has the correct question number" do - expect(question.question_number).to eq(84) - end + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "1" => { "value" => "Internal transfer", "hint" => "Where the tenant has moved to another social property owned by the same landlord." }, + "2" => { "value" => "Tenant applied directly (no referral or nomination)" }, + "3" => { "value" => "Nominated by a local housing authority" }, + "8" => { "value" => "Re-located through official housing mobility scheme" }, + "10" => { "value" => "Other social landlord" }, + "9" => { "value" => "Community learning disability team" }, + "14" => { "value" => "Community mental health team" }, + "15" => { "value" => "Health service" }, + "18" => { "value" => "Police, probation, prison or youth offending team – tenant had custodial sentence" }, + "19" => { "value" => "Police, probation, prison or youth offending team – no custodial sentence" }, + "7" => { "value" => "Voluntary agency" }, + "17" => { "value" => "Children’s Social Care" }, + "16" => { "value" => "Other" }, + }) + end + + it "has the correct question number" do + expect(question.question_number).to eq(84) end end