Browse Source

CLDC-4402: simplify some start_year_2024_or_later uses p1

CLDC-4402-audit-start-year-2024-or-later-usage-2
Rebecca Jesson 4 weeks ago
parent
commit
ce13bea9d8
  1. 4
      app/models/derived_variables/lettings_log_variables.rb
  2. 4
      app/models/derived_variables/sales_log_variables.rb
  3. 14
      app/models/form/lettings/pages/lead_tenant_nationality.rb
  4. 12
      app/models/form/lettings/pages/uprn.rb
  5. 4
      app/models/form/lettings/questions/age.rb
  6. 15
      app/models/form/lettings/questions/declaration.rb
  7. 23
      app/models/form/lettings/questions/ethnic_white.rb
  8. 4
      app/models/form/lettings/questions/first_time_property_let_as_social_housing.rb
  9. 19
      app/models/form/lettings/questions/housingneeds_other.rb
  10. 15
      app/models/form/lettings/questions/is_carehome.rb
  11. 14
      app/models/form/lettings/questions/layear.rb
  12. 26
      app/models/form/lettings/questions/letting_allocation.rb
  13. 23
      app/models/form/lettings/questions/nationality.rb
  14. 27
      app/models/form/lettings/questions/person_relationship.rb
  15. 12
      app/models/form/lettings/questions/previous_let_type.rb
  16. 31
      app/models/form/lettings/questions/reason_renewal.rb
  17. 132
      app/models/form/lettings/questions/referral_general_needs_prp.rb
  18. 12
      app/models/form/sales/pages/uprn.rb
  19. 7
      app/models/sales_log.rb
  20. 59
      spec/models/form/lettings/questions/declaration_spec.rb
  21. 38
      spec/models/form/lettings/questions/ethnic_white_spec.rb
  22. 32
      spec/models/form/lettings/questions/first_time_property_let_as_social_housing_spec.rb
  23. 34
      spec/models/form/lettings/questions/housingneeds_other_spec.rb
  24. 30
      spec/models/form/lettings/questions/is_carehome_spec.rb
  25. 23
      spec/models/form/lettings/questions/layear_spec.rb
  26. 41
      spec/models/form/lettings/questions/letting_allocation_spec.rb
  27. 36
      spec/models/form/lettings/questions/nationality_spec.rb
  28. 6
      spec/models/form/lettings/questions/person_relationship_spec.rb
  29. 32
      spec/models/form/lettings/questions/previous_let_type_spec.rb
  30. 46
      spec/models/form/lettings/questions/reason_renewal_spec.rb
  31. 78
      spec/models/form/lettings/questions/referral_general_needs_prp_spec.rb

4
app/models/derived_variables/lettings_log_variables.rb

@ -68,7 +68,7 @@ module DerivedVariables::LettingsLogVariables
self.has_benefits = get_has_benefits self.has_benefits = get_has_benefits
self.tshortfall_known = 0 if tshortfall self.tshortfall_known = 0 if tshortfall
self.nocharge = household_charge # Nocharge: 0 = No, 1 = Yes, Household charge: 0 = Yes, 1 = No 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 self.beds = 1
end end
if bedsit_changed_to_not_bedsit? # make user answer num of bedrooms again if bedsit_changed_to_not_bedsit? # make user answer num of bedrooms again
@ -280,7 +280,7 @@ private
self.wchair = nil self.wchair = nil
self.location_id = nil self.location_id = nil
end 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 self.beds = nil
end end
end end

4
app/models/derived_variables/sales_log_variables.rb

@ -29,7 +29,7 @@ module DerivedVariables::SalesLogVariables
end end
end end
if saledate && form.start_year_2024_or_later? && discounted_ownership_sale? if saledate && discounted_ownership_sale?
self.ppostcode_full = postcode_full self.ppostcode_full = postcode_full
self.ppcodenk = pcodenk self.ppcodenk = pcodenk
self.prevloc = la self.prevloc = la
@ -44,7 +44,7 @@ module DerivedVariables::SalesLogVariables
self.hhmemb = number_of_household_members self.hhmemb = number_of_household_members
self.hhtype = household_type self.hhtype = household_type
if saledate && form.start_year_2024_or_later? if saledate
self.soctenant = soctenant_from_prevten_values self.soctenant = soctenant_from_prevten_values
clear_child_ecstat_for_age_changes! clear_child_ecstat_for_age_changes!
child_under_16_constraints! child_under_16_constraints!

14
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) def initialize(id, hsh, subsection)
super super
@id = "lead_tenant_nationality" @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 }] @depends_on = [{ "declaration" => 1 }]
end end
def questions def questions
@questions ||= if form.start_year_2024_or_later? @questions ||= [
[ Form::Lettings::Questions::NationalityAllGroup.new(nil, nil, self),
Form::Lettings::Questions::NationalityAllGroup.new(nil, nil, self), Form::Lettings::Questions::NationalityAll.new(nil, nil, self),
Form::Lettings::Questions::NationalityAll.new(nil, nil, self), ]
]
else
[Form::Lettings::Questions::Nationality.new(nil, nil, self)]
end
end end
end end

12
app/models/form/lettings/pages/uprn.rb

@ -14,20 +14,12 @@ class Form::Lettings::Pages::Uprn < ::Form::Page
end end
def skip_text def skip_text
if form.start_year_2024_or_later? "Search for address instead"
"Search for address instead"
else
"Enter address instead"
end
end end
def skip_href(log = nil) def skip_href(log = nil)
return unless log return unless log
if form.start_year_2024_or_later? "address-matcher"
"address-matcher"
else
"address"
end
end end
end end

4
app/models/form/lettings/questions/age.rb

@ -33,8 +33,6 @@ class Form::Lettings::Questions::Age < ::Form::Question
end end
def hint_text def hint_text
if form.start_year_2024_or_later? "Answer 1 for children aged under 1 year old"
"Answer 1 for children aged under 1 year old"
end
end end
end end

15
app/models/form/lettings/questions/declaration.rb

@ -3,27 +3,16 @@ class Form::Lettings::Questions::Declaration < ::Form::Question
super super
@id = "declaration" @id = "declaration"
@type = "checkbox" @type = "checkbox"
@check_answers_card_number = 0 unless form.start_year_2024_or_later?
@top_guidance_partial = "privacy_notice_tenant" @top_guidance_partial = "privacy_notice_tenant"
@question_number = get_question_number_from_hash(QUESTION_NUMBER_FROM_YEAR) @question_number = get_question_number_from_hash(QUESTION_NUMBER_FROM_YEAR)
end end
def answer_options def answer_options
declaration_text = if form.start_year_2024_or_later? { "declaration" => { "value" => "The tenant has seen or been given access to the MHCLG privacy notice" } }.freeze
"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
end end
def unanswered_error_message(_log = nil) def unanswered_error_message(_log = nil)
if form.start_year_2024_or_later? I18n.t("validations.declaration.missing.post_2024")
I18n.t("validations.declaration.missing.post_2024")
else
I18n.t("validations.declaration.missing.pre_2024")
end
end end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 30, 2024 => 11, 2025 => 11, 2026 => 11 }.freeze QUESTION_NUMBER_FROM_YEAR = { 2023 => 30, 2024 => 11, 2025 => 11, 2026 => 11 }.freeze

23
app/models/form/lettings/questions/ethnic_white.rb

@ -9,22 +9,13 @@ class Form::Lettings::Questions::EthnicWhite < ::Form::Question
end end
def answer_options def answer_options
if form.start_year_2024_or_later? {
{ "1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" },
"1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" }, "2" => { "value" => "Irish" },
"2" => { "value" => "Irish" }, "18" => { "value" => "Gypsy or Irish Traveller" },
"18" => { "value" => "Gypsy or Irish Traveller" }, "20" => { "value" => "Roma" },
"20" => { "value" => "Roma" }, "3" => { "value" => "Any other White background" },
"3" => { "value" => "Any other White background" }, }.freeze
}.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
end end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 35, 2024 => 34, 2025 => 34, 2026 => 34 }.freeze QUESTION_NUMBER_FROM_YEAR = { 2023 => 35, 2024 => 34, 2025 => 34, 2026 => 34 }.freeze

4
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 end
def yes_hint 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 end
def no_hint 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 end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 14, 2024 => 15, 2025 => 12, 2026 => 12 }.freeze QUESTION_NUMBER_FROM_YEAR = { 2023 => 14, 2024 => 15, 2025 => 12, 2026 => 12 }.freeze

19
app/models/form/lettings/questions/housingneeds_other.rb

@ -9,19 +9,12 @@ class Form::Lettings::Questions::HousingneedsOther < ::Form::Question
end end
def answer_options def answer_options
if form.start_year_2024_or_later? {
{ "1" => { "value" => "Yes" },
"1" => { "value" => "Yes" }, "0" => { "value" => "No" },
"0" => { "value" => "No" }, "divider" => { "value" => true },
"divider" => { "value" => true }, "2" => { "value" => "Don’t know" },
"2" => { "value" => "Don’t know" }, }.freeze
}.freeze
else
{
"1" => { "value" => "Yes" },
"0" => { "value" => "No" },
}.freeze
end
end end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 72, 2024 => 71, 2025 => 71, 2026 => 78 }.freeze QUESTION_NUMBER_FROM_YEAR = { 2023 => 72, 2024 => 71, 2025 => 71, 2026 => 78 }.freeze

15
app/models/form/lettings/questions/is_carehome.rb

@ -10,17 +10,10 @@ class Form::Lettings::Questions::IsCarehome < ::Form::Question
end end
def answer_options def answer_options
if form.start_year_2024_or_later? {
{ "1" => { "value" => "Yes" },
"1" => { "value" => "Yes" }, "0" => { "value" => "No" },
"0" => { "value" => "No" }, }.freeze
}.freeze
else
{
"0" => { "value" => "No" },
"1" => { "value" => "Yes" },
}.freeze
end
end end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 93, 2024 => 92, 2025 => 92, 2026 => 100 }.freeze QUESTION_NUMBER_FROM_YEAR = { 2023 => 93, 2024 => 92, 2025 => 92, 2026 => 100 }.freeze

14
app/models/form/lettings/questions/layear.rb

@ -21,7 +21,7 @@ class Form::Lettings::Questions::Layear < ::Form::Question
"divider" => { "value" => true }, "divider" => { "value" => true },
"6" => { "value" => "Don’t know" }, "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" }, "1" => { "value" => "Just moved to local authority area with this new let" },
"2" => { "value" => "Less than 1 year" }, "2" => { "value" => "Less than 1 year" },
@ -34,18 +34,6 @@ class Form::Lettings::Questions::Layear < ::Form::Question
"divider" => { "value" => true }, "divider" => { "value" => true },
"6" => { "value" => "Don’t know" }, "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
end end

26
app/models/form/lettings/questions/letting_allocation.rb

@ -8,24 +8,14 @@ class Form::Lettings::Questions::LettingAllocation < ::Form::Question
end end
def answer_options 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." },
"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." },
"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." },
"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." },
"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 },
"divider" => { "value" => true }, "letting_allocation_unknown" => { "value" => "None of these allocation systems" },
"letting_allocation_unknown" => { "value" => "None of these allocation systems" }, }.freeze
}.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
end end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 84, 2024 => 83, 2025 => 83, 2026 => 90 }.freeze QUESTION_NUMBER_FROM_YEAR = { 2023 => 84, 2024 => 83, 2025 => 83, 2026 => 90 }.freeze

23
app/models/form/lettings/questions/nationality.rb

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

27
app/models/form/lettings/questions/person_relationship.rb

@ -10,26 +10,13 @@ class Form::Lettings::Questions::PersonRelationship < ::Form::Question
end end
def answer_options def answer_options
if form.start_year_2024_or_later? {
{ "P" => { "value" => "Partner" },
"P" => { "value" => "Partner" }, "C" => { "value" => "Child" },
"C" => { "value" => "Child" }, "X" => { "value" => "Other" },
"X" => { "value" => "Other" }, "divider" => { "value" => true },
"divider" => { "value" => true }, "R" => { "value" => "Person prefers not to say" },
"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
end end
def question_number def question_number

12
app/models/form/lettings/questions/previous_let_type.rb

@ -8,17 +8,6 @@ class Form::Lettings::Questions::PreviousLetType < ::Form::Question
end end
ANSWER_OPTIONS = { 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" }, "1" => { "value" => "Social rent basis" },
"2" => { "value" => "Affordable rent basis" }, "2" => { "value" => "Affordable rent basis" },
"5" => { "value" => "London Affordable Rent basis" }, "5" => { "value" => "London Affordable Rent basis" },
@ -45,7 +34,6 @@ class Form::Lettings::Questions::PreviousLetType < ::Form::Question
def answer_options def answer_options
return ANSWER_OPTIONS_AFTER_2025 if form.start_year_2025_or_later? 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 ANSWER_OPTIONS
end end

31
app/models/form/lettings/questions/reason_renewal.rb

@ -14,27 +14,16 @@ class Form::Lettings::Questions::ReasonRenewal < ::Form::Question
end end
def answer_options def answer_options
if form.start_year_2024_or_later? {
{ "50" => { "value" => "End of social or private sector tenancy - no fault" },
"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)" },
"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" },
"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" },
"53" => { "value" => "End of social or private sector tenancy - evicted for any other reason" }, "20" => { "value" => "Other" },
"20" => { "value" => "Other" }, "47" => { "value" => "Tenant prefers not to say" },
"47" => { "value" => "Tenant prefers not to say" }, "divider" => { "value" => true },
"divider" => { "value" => true }, "28" => { "value" => "Don’t know" },
"28" => { "value" => "Don’t know" }, }.freeze
}.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
end end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 77, 2024 => 76, 2025 => 76, 2026 => 83 }.freeze QUESTION_NUMBER_FROM_YEAR = { 2023 => 77, 2024 => 76, 2025 => 76, 2026 => 83 }.freeze

132
app/models/form/lettings/questions/referral_general_needs_prp.rb

@ -10,96 +10,48 @@ class Form::Lettings::Questions::ReferralGeneralNeedsPrp < ::Form::Question
end end
def answer_options def answer_options
if form.start_year_2024_or_later? {
{ "1" => {
"1" => { "value" => "Internal transfer",
"value" => "Internal transfer", "hint" => "Where the tenant has moved to another social property owned by the same landlord.",
"hint" => "Where the tenant has moved to another social property owned by the same landlord.", },
}, "2" => {
"2" => { "value" => "Tenant applied directly (no referral or nomination)",
"value" => "Tenant applied directly (no referral or nomination)", },
}, "3" => {
"3" => { "value" => "Nominated by a local housing authority",
"value" => "Nominated by a local housing authority", },
}, "8" => {
"8" => { "value" => "Re-located through official housing mobility scheme",
"value" => "Re-located through official housing mobility scheme", },
}, "10" => {
"10" => { "value" => "Other social landlord",
"value" => "Other social landlord", },
}, "9" => {
"9" => { "value" => "Community learning disability team",
"value" => "Community learning disability team", },
}, "14" => {
"14" => { "value" => "Community mental health team",
"value" => "Community mental health team", },
}, "15" => {
"15" => { "value" => "Health service",
"value" => "Health service", },
}, "18" => {
"18" => { "value" => "Police, probation, prison or youth offending team – tenant had custodial sentence",
"value" => "Police, probation, prison or youth offending team – tenant had custodial sentence", },
}, "19" => {
"19" => { "value" => "Police, probation, prison or youth offending team – no custodial sentence",
"value" => "Police, probation, prison or youth offending team – no custodial sentence", },
}, "7" => {
"7" => { "value" => "Voluntary agency",
"value" => "Voluntary agency", },
}, "17" => {
"17" => { "value" => "Children’s Social Care",
"value" => "Children’s Social Care", },
}, "16" => {
"16" => { "value" => "Other",
"value" => "Other", },
}, }.freeze
}.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
end end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 85, 2024 => 84, 2025 => 84 }.freeze QUESTION_NUMBER_FROM_YEAR = { 2023 => 85, 2024 => 84, 2025 => 84 }.freeze

12
app/models/form/sales/pages/uprn.rb

@ -13,20 +13,12 @@ class Form::Sales::Pages::Uprn < ::Form::Page
end end
def skip_text def skip_text
if form.start_year_2024_or_later? "Search for address instead"
"Search for address instead"
else
"Enter address instead"
end
end end
def skip_href(log = nil) def skip_href(log = nil)
return unless log return unless log
if form.start_year_2024_or_later? "address-matcher"
"address-matcher"
else
"address"
end
end end
end end

7
app/models/sales_log.rb

@ -142,7 +142,7 @@ class SalesLog < Log
def dynamically_not_required def dynamically_not_required
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 += %w[address_line2 county]
not_required not_required
@ -473,7 +473,6 @@ class SalesLog < Log
def should_process_address_change? def should_process_address_change?
return unless uprn_selection || select_best_address_match return unless uprn_selection || select_best_address_match
return unless saledate return unless saledate
return unless form.start_year_2024_or_later?
return if skip_address_lookup return if skip_address_lookup
if select_best_address_match if select_best_address_match
@ -552,10 +551,6 @@ class SalesLog < Log
form.start_year_2026_or_later? ? "sexrab1" : "sex1"].compact form.start_year_2026_or_later? ? "sexrab1" : "sex1"].compact
end end
def soctenant_is_inferred?
form.start_year_2024_or_later?
end
def duplicates def duplicates
return SalesLog.none if duplicate_set_id.nil? return SalesLog.none if duplicate_set_id.nil?

59
spec/models/form/lettings/questions/declaration_spec.rb

@ -1,16 +1,17 @@
require "rails_helper" require "rails_helper"
RSpec.describe Form::Lettings::Questions::Declaration, type: :model do RSpec.describe Form::Lettings::Questions::Declaration, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) } subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil } let(:question_id) { nil }
let(:question_definition) { nil } let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) } let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection) } 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 before do
allow(form).to receive(:start_year_2024_or_later?)
allow(page).to receive(:subsection).and_return(subsection) allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form) allow(subsection).to receive(:form).and_return(form)
end end
@ -31,51 +32,21 @@ RSpec.describe Form::Lettings::Questions::Declaration, type: :model do
expect(question.derived?(nil)).to be false expect(question.derived?(nil)).to be false
end end
context "when the form year is before 2024" do it "has the correct answer_options" do
before do expect(question.answer_options).to eq({
allow(form).to receive(:start_year_2024_or_later?).and_return(false) "declaration" => { "value" => "The tenant has seen or been given access to the MHCLG privacy notice" },
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
end end
context "when the form year is >= 2024" do it "uses the expected top guidance partial" do
before do expect(question.top_guidance_partial).to eq("privacy_notice_tenant")
allow(form).to receive(:start_year_2024_or_later?).and_return(true) end
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 "has check_answers_card_number nil" do it "has check_answers_card_number nil" do
expect(question.check_answers_card_number).to be_nil expect(question.check_answers_card_number).to be_nil
end end
it "returns correct unanswered_error_message" do 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.") 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 end
end end

38
spec/models/form/lettings/questions/ethnic_white_spec.rb

@ -1,16 +1,17 @@
require "rails_helper" require "rails_helper"
RSpec.describe Form::Lettings::Questions::EthnicWhite, type: :model do RSpec.describe Form::Lettings::Questions::EthnicWhite, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) } subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil } let(:question_id) { nil }
let(:question_definition) { nil } let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) } let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection) } 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 before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(page).to receive(:subsection).and_return(subsection) allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form) allow(subsection).to receive(:form).and_return(form)
end end
@ -31,31 +32,14 @@ RSpec.describe Form::Lettings::Questions::EthnicWhite, type: :model do
expect(question.derived?(nil)).to be false expect(question.derived?(nil)).to be false
end end
context "with 2023/24 form" do it "has the correct answer_options" do
it "has the correct answer_options" do expect(question.answer_options).to eq({
expect(question.answer_options).to eq({ "1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" },
"1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" }, "2" => { "value" => "Irish" },
"2" => { "value" => "Irish" }, "18" => { "value" => "Gypsy or Irish Traveller" },
"18" => { "value" => "Gypsy or Irish Traveller" }, "20" => { "value" => "Roma" },
"3" => { "value" => "Any other White background" }, "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
end end
it "has the correct check_answers_card_number" do it "has the correct check_answers_card_number" do

32
spec/models/form/lettings/questions/first_time_property_let_as_social_housing_spec.rb

@ -1,16 +1,17 @@
require "rails_helper" require "rails_helper"
RSpec.describe Form::Lettings::Questions::FirstTimePropertyLetAsSocialHousing, type: :model do RSpec.describe Form::Lettings::Questions::FirstTimePropertyLetAsSocialHousing, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) } subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil } let(:question_id) { nil }
let(:question_definition) { nil } let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) } let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection) } 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 before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(page).to receive(:subsection).and_return(subsection) allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form) allow(subsection).to receive(:form).and_return(form)
end end
@ -23,29 +24,16 @@ RSpec.describe Form::Lettings::Questions::FirstTimePropertyLetAsSocialHousing, t
expect(question.id).to eq("first_time_property_let_as_social_housing") expect(question.id).to eq("first_time_property_let_as_social_housing")
end end
context "with 2023/24 form" do it "has the correct answer_options" do
it "has the correct answer_options" do expect(question.answer_options).to eq({
expect(question.answer_options).to eq({ "1" => { "value" => "Yes", "hint" => "This property was previously used for other purposes or is a new-build." },
"1" => { "value" => "Yes", "hint" => "This is a new let." }, "0" => { "value" => "No", "hint" => "This is a re-let of existing social housing stock." },
"0" => { "value" => "No", "hint" => "This is a re-let of existing social housing." }, })
})
end
end end
context "with 2024/25 form" do context "with 2024/25 form" do
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } 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 it "has the correct question number" do
expect(question.question_number).to eq(15) expect(question.question_number).to eq(15)
end end
@ -54,10 +42,6 @@ RSpec.describe Form::Lettings::Questions::FirstTimePropertyLetAsSocialHousing, t
context "with 2025/26 form" do context "with 2025/26 form" do
let(:form) { instance_double(Form, start_date: Time.zone.local(2025, 4, 1)) } 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 it "has the correct question number" do
expect(question.question_number).to eq(12) expect(question.question_number).to eq(12)
end end

34
spec/models/form/lettings/questions/housingneeds_other_spec.rb

@ -1,16 +1,17 @@
require "rails_helper" require "rails_helper"
RSpec.describe Form::Lettings::Questions::HousingneedsOther, type: :model do RSpec.describe Form::Lettings::Questions::HousingneedsOther, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) } subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil } let(:question_id) { nil }
let(:question_definition) { nil } let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) } let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection) } 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 before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(page).to receive(:subsection).and_return(subsection) allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form) allow(subsection).to receive(:form).and_return(form)
end end
@ -31,28 +32,13 @@ RSpec.describe Form::Lettings::Questions::HousingneedsOther, type: :model do
expect(question.derived?(nil)).to be false expect(question.derived?(nil)).to be false
end end
context "with 2023/24 form" do it "has the correct answer_options" do
it "has the correct answer_options" do expect(question.answer_options).to eq({
expect(question.answer_options).to eq({ "1" => { "value" => "Yes" },
"1" => { "value" => "Yes" }, "0" => { "value" => "No" },
"0" => { "value" => "No" }, "divider" => { "value" => true },
}) "2" => { "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({
"1" => { "value" => "Yes" },
"0" => { "value" => "No" },
"divider" => { "value" => true },
"2" => { "value" => "Don’t know" },
})
end
end end
it "has the correct check_answers_card_number" do it "has the correct check_answers_card_number" do

30
spec/models/form/lettings/questions/is_carehome_spec.rb

@ -1,16 +1,17 @@
require "rails_helper" require "rails_helper"
RSpec.describe Form::Lettings::Questions::IsCarehome, type: :model do RSpec.describe Form::Lettings::Questions::IsCarehome, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) } subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil } let(:question_id) { nil }
let(:question_definition) { nil } let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) } let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection) } 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 before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(page).to receive(:subsection).and_return(subsection) allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form) allow(subsection).to receive(:form).and_return(form)
end end
@ -31,26 +32,11 @@ RSpec.describe Form::Lettings::Questions::IsCarehome, type: :model do
expect(question.derived?(nil)).to be false expect(question.derived?(nil)).to be false
end end
context "with 2023/24 form" do it "has the correct answer_options in the correct order" do
it "has the correct answer_options in the correct order" do expect(question.answer_options.map { |k, v| [k, v["value"]] }).to eq([
expect(question.answer_options.map { |k, v| [k, v["value"]] }).to eq([ %w[1 Yes],
%w[0 No], %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
end end
it "has the correct check_answers_card_number" do it "has the correct check_answers_card_number" do

23
spec/models/form/lettings/questions/layear_spec.rb

@ -1,16 +1,17 @@
require "rails_helper" require "rails_helper"
RSpec.describe Form::Lettings::Questions::Layear, type: :model do RSpec.describe Form::Lettings::Questions::Layear, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) } subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil } let(:question_id) { nil }
let(:question_definition) { nil } let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) } let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection) } 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 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(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form) allow(subsection).to receive(:form).and_return(form)
end end
@ -31,25 +32,9 @@ RSpec.describe Form::Lettings::Questions::Layear, type: :model do
expect(question.derived?(nil)).to be false expect(question.derived?(nil)).to be false
end 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 context "with 2024/25 form" do
before 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 end
it "has the correct answer_options" do it "has the correct answer_options" do

41
spec/models/form/lettings/questions/letting_allocation_spec.rb

@ -1,16 +1,17 @@
require "rails_helper" require "rails_helper"
RSpec.describe Form::Lettings::Questions::LettingAllocation, type: :model do RSpec.describe Form::Lettings::Questions::LettingAllocation, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) } subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil } let(:question_id) { nil }
let(:question_definition) { nil } let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) } let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection) } 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 before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(page).to receive(:subsection).and_return(subsection) allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form) allow(subsection).to receive(:form).and_return(form)
end end
@ -31,33 +32,15 @@ RSpec.describe Form::Lettings::Questions::LettingAllocation, type: :model do
expect(question.derived?(nil)).to be false expect(question.derived?(nil)).to be false
end end
context "with 2023/24 form" do it "has the correct answer_options" do
it "has the correct answer_options" do expect(question.answer_options).to eq({
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." },
"cbl" => { "value" => "Choice-based lettings (CBL)" }, "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." },
"cap" => { "value" => "Common Allocation Policy (CAP)" }, "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." },
"chr" => { "value" => "Common housing register (CHR)" }, "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 }, "divider" => { "value" => true },
"letting_allocation_unknown" => { "value" => "None of these allocation systems" }, "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
end end
it "has the correct check_answers_card_number" do it "has the correct check_answers_card_number" do

36
spec/models/form/lettings/questions/nationality_spec.rb

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

6
spec/models/form/lettings/questions/person_relationship_spec.rb

@ -1,10 +1,12 @@
require "rails_helper" require "rails_helper"
RSpec.describe Form::Lettings::Questions::PersonRelationship, type: :model do RSpec.describe Form::Lettings::Questions::PersonRelationship, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(nil, question_definition, page, person_index:) } subject(:question) { described_class.new(nil, question_definition, page, person_index:) }
let(:question_definition) { nil } let(:question_definition) { nil }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 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 } let(:person_index) { 2 }
it "has correct page" do it "has correct page" do
@ -20,7 +22,7 @@ RSpec.describe Form::Lettings::Questions::PersonRelationship, type: :model do
end end
it "has the correct answer_options" do 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" }, "P" => { "value" => "Partner" },
"R" => { "value" => "Person prefers not to say" }, "R" => { "value" => "Person prefers not to say" },
"X" => { "value" => "Other" }, "X" => { "value" => "Other" },

32
spec/models/form/lettings/questions/previous_let_type_spec.rb

@ -1,14 +1,15 @@
require "rails_helper" require "rails_helper"
RSpec.describe Form::Lettings::Questions::PreviousLetType, type: :model do RSpec.describe Form::Lettings::Questions::PreviousLetType, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(nil, nil, page) } subject(:question) { described_class.new(nil, nil, page) }
let(:page) { instance_double(Form::Page) } let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection) } 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 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(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form) allow(subsection).to receive(:form).and_return(form)
end end
@ -29,25 +30,8 @@ RSpec.describe Form::Lettings::Questions::PreviousLetType, type: :model do
expect(question.derived?(nil)).to be false expect(question.derived?(nil)).to be false
end end
it "has the correct answer options" do context "with 2024/25 form" do
expect(question.answer_options).to eq({ let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1), start_year_2025_or_later?: false) }
"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
it "has the correct answer options" do it "has the correct answer options" do
expect(question.answer_options).to eq({ expect(question.answer_options).to eq({
@ -68,11 +52,7 @@ RSpec.describe Form::Lettings::Questions::PreviousLetType, type: :model do
end end
context "with collection year on or after 2025" do context "with collection year on or after 2025" do
let(:form) { instance_double(Form, start_date: Time.zone.local(2025, 4, 1)) } let(:form) { instance_double(Form, start_date: Time.zone.local(2025, 4, 1), start_year_2025_or_later?: true) }
before do
allow(form).to receive(:start_year_2025_or_later?).and_return(true)
end
it "has the correct answer options" do it "has the correct answer options" do
expect(question.answer_options).to eq({ expect(question.answer_options).to eq({

46
spec/models/form/lettings/questions/reason_renewal_spec.rb

@ -1,16 +1,17 @@
require "rails_helper" require "rails_helper"
RSpec.describe Form::Lettings::Questions::ReasonRenewal, type: :model do RSpec.describe Form::Lettings::Questions::ReasonRenewal, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) } subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil } let(:question_id) { nil }
let(:question_definition) { nil } let(:question_definition) { nil }
let(:page) { instance_double(Form::Page, id: "reason_renewal") } let(:page) { instance_double(Form::Page, id: "reason_renewal") }
let(:subsection) { instance_double(Form::Subsection) } 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 before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(page).to receive(:subsection).and_return(subsection) allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form) allow(subsection).to receive(:form).and_return(form)
end end
@ -39,35 +40,16 @@ RSpec.describe Form::Lettings::Questions::ReasonRenewal, type: :model do
expect(question).not_to be_derived(nil) expect(question).not_to be_derived(nil)
end end
context "with 2023/24 form" do it "has the correct answer_options" do
it "has the correct answer_options" do expect(question.answer_options).to eq({
expect(question.answer_options).to eq({ "50" => { "value" => "End of social or private sector tenancy - no fault" },
"40" => { "value" => "End of assured shorthold tenancy (no fault)" }, "51" => { "value" => "End of social or private sector tenancy - evicted due to anti-social behaviour (ASB)" },
"42" => { "value" => "End of fixed term tenancy (no fault)" }, "52" => { "value" => "End of social or private sector tenancy - evicted due to rent arrears" },
"20" => { "value" => "Other" }, "53" => { "value" => "End of social or private sector tenancy - evicted for any other reason" },
"47" => { "value" => "Tenant prefers not to say" }, "20" => { "value" => "Other" },
"divider" => { "value" => true }, "47" => { "value" => "Tenant prefers not to say" },
"28" => { "value" => "Don’t know" }, "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
end end
end end

78
spec/models/form/lettings/questions/referral_general_needs_prp_spec.rb

@ -1,16 +1,17 @@
require "rails_helper" require "rails_helper"
RSpec.describe Form::Lettings::Questions::ReferralGeneralNeedsPrp, type: :model do RSpec.describe Form::Lettings::Questions::ReferralGeneralNeedsPrp, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) } subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil } let(:question_id) { nil }
let(:question_definition) { nil } let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) } let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection) } 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 before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(page).to receive(:subsection).and_return(subsection) allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form) allow(subsection).to receive(:form).and_return(form)
end end
@ -35,58 +36,25 @@ RSpec.describe Form::Lettings::Questions::ReferralGeneralNeedsPrp, type: :model
expect(question).not_to be_derived(nil) expect(question).not_to be_derived(nil)
end end
context "with 2023/24 form" do it "has the correct answer_options" do
it "has the correct answer_options" do expect(question.answer_options).to eq({
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." },
"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)" },
"2" => { "value" => "Tenant applied directly (no referral or nomination)" }, "3" => { "value" => "Nominated by a local housing authority" },
"3" => { "value" => "Nominated by a local housing authority" }, "8" => { "value" => "Re-located through official housing mobility scheme" },
"4" => { "value" => "Referred by local authority housing department" }, "10" => { "value" => "Other social landlord" },
"8" => { "value" => "Re-located through official housing mobility scheme" }, "9" => { "value" => "Community learning disability team" },
"10" => { "value" => "Other social landlord" }, "14" => { "value" => "Community mental health team" },
"9" => { "value" => "Community learning disability team" }, "15" => { "value" => "Health service" },
"14" => { "value" => "Community mental health team" }, "18" => { "value" => "Police, probation, prison or youth offending team – tenant had custodial sentence" },
"15" => { "value" => "Health service" }, "19" => { "value" => "Police, probation, prison or youth offending team – no custodial sentence" },
"12" => { "value" => "Police, probation or prison" }, "7" => { "value" => "Voluntary agency" },
"7" => { "value" => "Voluntary agency" }, "17" => { "value" => "Children’s Social Care" },
"13" => { "value" => "Youth offending team" }, "16" => { "value" => "Other" },
"17" => { "value" => "Children’s Social Care" }, })
"16" => { "value" => "Other" }, end
})
end it "has the correct question number" do
expect(question.question_number).to eq(84)
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
end end
end end

Loading…
Cancel
Save