Browse Source

CLDC-4402: simplify some start_year_2024_or_later uses p2

CLDC-4402-audit-start-year-2024-or-later-usage-2
Rebecca Jesson 4 weeks ago
parent
commit
b5d4b16aa9
  1. 120
      app/models/form/lettings/questions/referral_general_needs.rb
  2. 120
      app/models/form/lettings/questions/referral_supported_housing.rb
  3. 138
      app/models/form/lettings/questions/referral_supported_housing_prp.rb
  4. 135
      app/models/form/lettings/questions/rsnvac.rb
  5. 80
      app/models/form/lettings/questions/starter_tenancy_type.rb
  6. 80
      app/models/form/lettings/questions/tenancy_type.rb
  7. 15
      app/models/form/lettings/questions/uprn_confirmation.rb
  8. 17
      app/models/form/lettings/questions/waityear.rb
  9. 74
      spec/models/form/lettings/questions/referral_general_needs_spec.rb
  10. 80
      spec/models/form/lettings/questions/referral_supported_housing_prp_spec.rb
  11. 74
      spec/models/form/lettings/questions/referral_supported_housing_spec.rb
  12. 152
      spec/models/form/lettings/questions/rsnvac_spec.rb
  13. 104
      spec/models/form/lettings/questions/starter_tenancy_type_spec.rb
  14. 47
      spec/models/form/lettings/questions/tenancy_type_spec.rb
  15. 24
      spec/models/form/lettings/questions/waityear_spec.rb

120
app/models/form/lettings/questions/referral_general_needs.rb

@ -10,87 +10,45 @@ class Form::Lettings::Questions::ReferralGeneralNeeds < ::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)",
},
"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)",
},
"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)",
},
"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

120
app/models/form/lettings/questions/referral_supported_housing.rb

@ -10,87 +10,45 @@ class Form::Lettings::Questions::ReferralSupportedHousing < ::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)",
},
"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)",
},
"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)",
},
"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

138
app/models/form/lettings/questions/referral_supported_housing_prp.rb

@ -10,99 +10,51 @@ class Form::Lettings::Questions::ReferralSupportedHousingPrp < ::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",
},
"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",
},
"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",
},
"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",
},
"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

135
app/models/form/lettings/questions/rsnvac.rb

@ -7,95 +7,52 @@ class Form::Lettings::Questions::Rsnvac < ::Form::Question
end
def answer_options
if form.start_year_2024_or_later?
{
"14" => {
"value" => "Renewal of fixed-term tenancy",
"hint" => "To the same tenant in the same property, except if was previously used as temporary accommodation.",
},
"9" => {
"value" => "Re-let to tenant who occupied same property as temporary accommodation",
},
"13" => {
"value" => "Internal transfer",
"hint" => "Where a tenant moved from one social housing property to another property. Their landlord may be the same or may have changed.",
},
"12" => {
"value" => "Tenant moved to other social housing provider",
},
"8" => {
"value" => "Tenant moved to private sector or other accommodation",
},
"18" => {
"value" => "Tenant moved to care home",
},
"20" => {
"value" => "Tenant moved to long-stay hospital or similar institution",
},
"5" => {
"value" => "Tenant died with no succession",
},
"19" => {
"value" => "Tenant involved in a succession downsize",
},
"6" => {
"value" => "Tenant abandoned property",
},
"10" => {
"value" => "Tenant was evicted due to rent arrears",
},
"11" => {
"value" => "Tenant was evicted due to anti-social behaviour",
},
"21" => {
"value" => "Tenant was evicted due to both rent arrears and anti-social behaviour",
},
"22" => {
"value" => "Any other reason",
},
}
else
{
"13" => {
"value" => "Internal transfer",
"hint" => "Where a tenant moved from one social housing property to another property. Their landlord may be the same or may have changed.",
},
"5" => {
"value" => "Previous tenant died with no succession",
},
"9" => {
"value" => "Re-let to tenant who occupied same property as temporary accommodation",
},
"14" => {
"value" => "Renewal of fixed-term tenancy",
"hint" => "To the same tenant in the same property, except if was previously used as temporary accommodation.",
},
"19" => {
"value" => "Tenant involved in a succession downsize",
},
"8" => {
"value" => "Tenant moved to private sector or other accommodation",
},
"12" => {
"value" => "Tenant moved to other social housing provider",
},
"18" => {
"value" => "Tenant moved to care home",
},
"20" => {
"value" => "Tenant moved to long-stay hospital or similar institution",
},
"6" => {
"value" => "Tenant abandoned property",
},
"10" => {
"value" => "Tenant was evicted due to rent arrears",
},
"11" => {
"value" => "Tenant was evicted due to anti-social behaviour",
},
}
end
{
"14" => {
"value" => "Renewal of fixed-term tenancy",
"hint" => "To the same tenant in the same property, except if was previously used as temporary accommodation.",
},
"9" => {
"value" => "Re-let to tenant who occupied same property as temporary accommodation",
},
"13" => {
"value" => "Internal transfer",
"hint" => "Where a tenant moved from one social housing property to another property. Their landlord may be the same or may have changed.",
},
"12" => {
"value" => "Tenant moved to other social housing provider",
},
"8" => {
"value" => "Tenant moved to private sector or other accommodation",
},
"18" => {
"value" => "Tenant moved to care home",
},
"20" => {
"value" => "Tenant moved to long-stay hospital or similar institution",
},
"5" => {
"value" => "Tenant died with no succession",
},
"19" => {
"value" => "Tenant involved in a succession downsize",
},
"6" => {
"value" => "Tenant abandoned property",
},
"10" => {
"value" => "Tenant was evicted due to rent arrears",
},
"11" => {
"value" => "Tenant was evicted due to anti-social behaviour",
},
"21" => {
"value" => "Tenant was evicted due to both rent arrears and anti-social behaviour",
},
"22" => {
"value" => "Any other reason",
},
}
end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 17, 2024 => 18, 2025 => 15, 2026 => 15 }.freeze

80
app/models/form/lettings/questions/starter_tenancy_type.rb

@ -10,59 +10,33 @@ class Form::Lettings::Questions::StarterTenancyType < ::Form::Question
end
def answer_options
if form.start_year_2024_or_later?
{
"4" => {
"value" => "Assured Shorthold Tenancy (AST) – Fixed term",
"hint" => "These are mostly provided by housing associations. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
},
"6" => {
"value" => "Secure – fixed term",
"hint" => "These are mostly provided by local authorities. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
},
"2" => {
"value" => "Assured – lifetime",
},
"7" => {
"value" => "Secure – lifetime",
},
"8" => {
"value" => "Periodic",
"hint" => "These are rolling tenancies with no fixed end date. They may have an initial fixed term and then become rolling.",
},
"5" => {
"value" => "Licence agreement",
"hint" => "These are mostly used for Supported Housing and work on a rolling basis.",
},
"3" => {
"value" => "Other",
},
}.freeze
else
{
"4" => {
"value" => "Assured Shorthold Tenancy (AST) – Fixed term",
"hint" => "Mostly housing associations provide these. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
},
"6" => {
"value" => "Secure – fixed term",
"hint" => "Mostly local authorities provide these. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
},
"2" => {
"value" => "Assured – lifetime",
},
"7" => {
"value" => "Secure – lifetime",
},
"5" => {
"value" => "Licence agreement",
"hint" => "Licence agreements are mostly used for Supported Housing and work on a rolling basis.",
},
"3" => {
"value" => "Other",
},
}.freeze
end
{
"4" => {
"value" => "Assured Shorthold Tenancy (AST) – Fixed term",
"hint" => "These are mostly provided by housing associations. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
},
"6" => {
"value" => "Secure – fixed term",
"hint" => "These are mostly provided by local authorities. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
},
"2" => {
"value" => "Assured – lifetime",
},
"7" => {
"value" => "Secure – lifetime",
},
"8" => {
"value" => "Periodic",
"hint" => "These are rolling tenancies with no fixed end date. They may have an initial fixed term and then become rolling.",
},
"5" => {
"value" => "Licence agreement",
"hint" => "These are mostly used for Supported Housing and work on a rolling basis.",
},
"3" => {
"value" => "Other",
},
}.freeze
end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 27, 2024 => 27, 2025 => 28, 2026 => 27 }.freeze

80
app/models/form/lettings/questions/tenancy_type.rb

@ -10,59 +10,33 @@ class Form::Lettings::Questions::TenancyType < ::Form::Question
end
def answer_options
if form.start_year_2024_or_later?
{
"4" => {
"value" => "Assured Shorthold Tenancy (AST) – Fixed term",
"hint" => "These are mostly provided by housing associations. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
},
"6" => {
"value" => "Secure – fixed term",
"hint" => "These are mostly provided by local authorities. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
},
"2" => {
"value" => "Assured – lifetime",
},
"7" => {
"value" => "Secure – lifetime",
},
"8" => {
"value" => "Periodic",
"hint" => "These are rolling tenancies with no fixed end date. They may have an initial fixed term and then become rolling.",
},
"5" => {
"value" => "Licence agreement",
"hint" => "These are mostly used for Supported Housing and work on a rolling basis.",
},
"3" => {
"value" => "Other",
},
}.freeze
else
{
"4" => {
"value" => "Assured Shorthold Tenancy (AST) – Fixed term",
"hint" => "Mostly housing associations provide these. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
},
"6" => {
"value" => "Secure – fixed term",
"hint" => "Mostly local authorities provide these. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
},
"2" => {
"value" => "Assured – lifetime",
},
"7" => {
"value" => "Secure – lifetime",
},
"5" => {
"value" => "Licence agreement",
"hint" => "Licence agreements are mostly used for Supported Housing and work on a rolling basis.",
},
"3" => {
"value" => "Other",
},
}.freeze
end
{
"4" => {
"value" => "Assured Shorthold Tenancy (AST) – Fixed term",
"hint" => "These are mostly provided by housing associations. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
},
"6" => {
"value" => "Secure – fixed term",
"hint" => "These are mostly provided by local authorities. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
},
"2" => {
"value" => "Assured – lifetime",
},
"7" => {
"value" => "Secure – lifetime",
},
"8" => {
"value" => "Periodic",
"hint" => "These are rolling tenancies with no fixed end date. They may have an initial fixed term and then become rolling.",
},
"5" => {
"value" => "Licence agreement",
"hint" => "These are mostly used for Supported Housing and work on a rolling basis.",
},
"3" => {
"value" => "Other",
},
}.freeze
end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 27, 2024 => 27, 2025 => 28, 2026 => 27 }.freeze

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

@ -8,17 +8,10 @@ class Form::Lettings::Questions::UprnConfirmation < ::Form::Question
end
def answer_options
if form.start_year_2024_or_later?
{
"1" => { "value" => "Yes" },
"0" => { "value" => "No, I want to search for the address instead" },
}.freeze
else
{
"1" => { "value" => "Yes" },
"0" => { "value" => "No, I want to enter the address manually" },
}.freeze
end
{
"1" => { "value" => "Yes" },
"0" => { "value" => "No, I want to search for the address instead" },
}.freeze
end
def notification_banner(log = nil)

17
app/models/form/lettings/questions/waityear.rb

@ -23,27 +23,14 @@ class Form::Lettings::Questions::Waityear < ::Form::Question
}.freeze
end
if form.start_year_2024_or_later?
return {
"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" },
"11" => { "value" => "5 years but under 10 years" },
"12" => { "value" => "10 years or more" },
"divider" => { "value" => true },
"6" => { "value" => "Don’t know" },
}.freeze
end
{
"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" },
"11" => { "value" => "5 years but under 10 years" },
"12" => { "value" => "10 years or more" },
"divider" => { "value" => true },
"6" => { "value" => "Don’t know" },
}.freeze

74
spec/models/form/lettings/questions/referral_general_needs_spec.rb

@ -1,16 +1,17 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::ReferralGeneralNeeds, 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,55 +36,24 @@ RSpec.describe Form::Lettings::Questions::ReferralGeneralNeeds, 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({
"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)" },
"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)" },
"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)" },
"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

80
spec/models/form/lettings/questions/referral_supported_housing_prp_spec.rb

@ -1,16 +1,17 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::ReferralSupportedHousingPrp, 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,59 +36,26 @@ RSpec.describe Form::Lettings::Questions::ReferralSupportedHousingPrp, type: :mo
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" },
"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" },
"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" },
"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" },
"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

74
spec/models/form/lettings/questions/referral_supported_housing_spec.rb

@ -1,16 +1,17 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::ReferralSupportedHousing, 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,55 +36,24 @@ RSpec.describe Form::Lettings::Questions::ReferralSupportedHousing, 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)" },
"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)" },
"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)" },
"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

152
spec/models/form/lettings/questions/rsnvac_spec.rb

@ -1,16 +1,17 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::Rsnvac, 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,107 +32,58 @@ RSpec.describe Form::Lettings::Questions::Rsnvac, 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({
"13" => {
"value" => "Internal transfer",
"hint" => "Where a tenant moved from one social housing property to another property. Their landlord may be the same or may have changed.",
},
"5" => {
"value" => "Previous tenant died with no succession",
},
"9" => {
"value" => "Re-let to tenant who occupied same property as temporary accommodation",
},
"14" => {
"value" => "Renewal of fixed-term tenancy",
"hint" => "To the same tenant in the same property, except if was previously used as temporary accommodation.",
},
"19" => {
"value" => "Tenant involved in a succession downsize",
},
"8" => {
"value" => "Tenant moved to private sector or other accommodation",
},
"12" => {
"value" => "Tenant moved to other social housing provider",
},
"18" => {
"value" => "Tenant moved to care home",
},
"20" => {
"value" => "Tenant moved to long-stay hospital or similar institution",
},
"6" => {
"value" => "Tenant abandoned property",
},
"10" => {
"value" => "Tenant was evicted due to rent arrears",
},
"11" => {
"value" => "Tenant was evicted due to anti-social behaviour",
},
})
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"14" => {
"value" => "Renewal of fixed-term tenancy",
"hint" => "To the same tenant in the same property, except if was previously used as temporary accommodation.",
},
"9" => {
"value" => "Re-let to tenant who occupied same property as temporary accommodation",
},
"13" => {
"value" => "Internal transfer",
"hint" => "Where a tenant moved from one social housing property to another property. Their landlord may be the same or may have changed.",
},
"12" => {
"value" => "Tenant moved to other social housing provider",
},
"8" => {
"value" => "Tenant moved to private sector or other accommodation",
},
"18" => {
"value" => "Tenant moved to care home",
},
"20" => {
"value" => "Tenant moved to long-stay hospital or similar institution",
},
"5" => {
"value" => "Tenant died with no succession",
},
"19" => {
"value" => "Tenant involved in a succession downsize",
},
"6" => {
"value" => "Tenant abandoned property",
},
"10" => {
"value" => "Tenant was evicted due to rent arrears",
},
"11" => {
"value" => "Tenant was evicted due to anti-social behaviour",
},
"21" => {
"value" => "Tenant was evicted due to both rent arrears and anti-social behaviour",
},
"22" => {
"value" => "Any other reason",
},
})
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({
"14" => {
"value" => "Renewal of fixed-term tenancy",
"hint" => "To the same tenant in the same property, except if was previously used as temporary accommodation.",
},
"9" => {
"value" => "Re-let to tenant who occupied same property as temporary accommodation",
},
"13" => {
"value" => "Internal transfer",
"hint" => "Where a tenant moved from one social housing property to another property. Their landlord may be the same or may have changed.",
},
"12" => {
"value" => "Tenant moved to other social housing provider",
},
"8" => {
"value" => "Tenant moved to private sector or other accommodation",
},
"18" => {
"value" => "Tenant moved to care home",
},
"20" => {
"value" => "Tenant moved to long-stay hospital or similar institution",
},
"5" => {
"value" => "Tenant died with no succession",
},
"19" => {
"value" => "Tenant involved in a succession downsize",
},
"6" => {
"value" => "Tenant abandoned property",
},
"10" => {
"value" => "Tenant was evicted due to rent arrears",
},
"11" => {
"value" => "Tenant was evicted due to anti-social behaviour",
},
"21" => {
"value" => "Tenant was evicted due to both rent arrears and anti-social behaviour",
},
"22" => {
"value" => "Any other reason",
},
})
end
it "has the correct question number" do
expect(question.question_number).to eq(18)
end
@ -140,10 +92,6 @@ RSpec.describe Form::Lettings::Questions::Rsnvac, type: :model do
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(15)
end

104
spec/models/form/lettings/questions/starter_tenancy_type_spec.rb

@ -1,92 +1,56 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::StarterTenancyType, 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: "starter_tenancy_type") }
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(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end
context "with 2023/24 form" 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(
{
"4" => {
"value" => "Assured Shorthold Tenancy (AST) – Fixed term",
"hint" => "Mostly housing associations provide these. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
},
"6" => {
"value" => "Secure – fixed term",
"hint" => "Mostly local authorities provide these. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
},
"2" => {
"value" => "Assured – lifetime",
},
"7" => {
"value" => "Secure – lifetime",
},
"5" => {
"value" => "Licence agreement",
"hint" => "Licence agreements are mostly used for Supported Housing and work on a rolling basis.",
},
"3" => {
"value" => "Other",
},
it "has the correct answer options" do
expect(question.answer_options).to eq(
{
"4" => {
"value" => "Assured Shorthold Tenancy (AST) – Fixed term",
"hint" => "These are mostly provided by housing associations. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
},
)
end
"6" => {
"value" => "Secure – fixed term",
"hint" => "These are mostly provided by local authorities. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
},
"2" => {
"value" => "Assured – lifetime",
},
"7" => {
"value" => "Secure – lifetime",
},
"8" => {
"value" => "Periodic",
"hint" => "These are rolling tenancies with no fixed end date. They may have an initial fixed term and then become rolling.",
},
"5" => {
"value" => "Licence agreement",
"hint" => "These are mostly used for Supported Housing and work on a rolling basis.",
},
"3" => {
"value" => "Other",
},
},
)
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(
{
"4" => {
"value" => "Assured Shorthold Tenancy (AST) – Fixed term",
"hint" => "These are mostly provided by housing associations. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
},
"6" => {
"value" => "Secure – fixed term",
"hint" => "These are mostly provided by local authorities. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
},
"2" => {
"value" => "Assured – lifetime",
},
"7" => {
"value" => "Secure – lifetime",
},
"8" => {
"value" => "Periodic",
"hint" => "These are rolling tenancies with no fixed end date. They may have an initial fixed term and then become rolling.",
},
"5" => {
"value" => "Licence agreement",
"hint" => "These are mostly used for Supported Housing and work on a rolling basis.",
},
"3" => {
"value" => "Other",
},
},
)
end
it "has the correct question number" do
expect(question.question_number).to eq(27)
end
@ -95,10 +59,6 @@ RSpec.describe Form::Lettings::Questions::StarterTenancyType, type: :model do
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(28)
end

47
spec/models/form/lettings/questions/tenancy_type_spec.rb

@ -1,15 +1,16 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::TenancyType, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(nil, nil, page) }
let(:page) { instance_double(Form::Page, id: "tenancy_type") }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form, start_date:) }
let(:start_date) { Time.utc(2023, 4, 1) }
let(: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
@ -30,47 +31,9 @@ RSpec.describe Form::Lettings::Questions::TenancyType, type: :model do
expect(question.conditional_for).to eq({ "tenancyother" => [3] })
end
context "with 2023/24 form" 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(
{
"4" => {
"value" => "Assured Shorthold Tenancy (AST) – Fixed term",
"hint" => "Mostly housing associations provide these. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
},
"6" => {
"value" => "Secure – fixed term",
"hint" => "Mostly local authorities provide these. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
},
"2" => {
"value" => "Assured – lifetime",
},
"7" => {
"value" => "Secure – lifetime",
},
"5" => {
"value" => "Licence agreement",
"hint" => "Licence agreements are mostly used for Supported Housing and work on a rolling basis.",
},
"3" => {
"value" => "Other",
},
},
)
end
end
context "with 2024/25 form" do
let(:start_date) { Time.utc(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(
{
@ -111,10 +74,6 @@ RSpec.describe Form::Lettings::Questions::TenancyType, type: :model do
context "with 2025/26 form" do
let(:start_date) { Time.utc(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(28)
end

24
spec/models/form/lettings/questions/waityear_spec.rb

@ -1,15 +1,16 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::Waityear, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(nil, question_definition, page) }
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
@ -42,24 +43,9 @@ RSpec.describe Form::Lettings::Questions::Waityear, type: :model do
expect(question.check_answers_card_number).to eq(0)
end
context "with 2023/24 form" do
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"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_messages(start_year_2025_or_later?: false)
end
it "has the correct answer_options" do
@ -79,7 +65,7 @@ RSpec.describe Form::Lettings::Questions::Waityear, type: :model do
context "with 2025/26 form" do
before do
allow(form).to receive(:start_year_2025_or_later?).and_return(true)
allow(form).to receive_messages(start_year_2025_or_later?: true)
end
it "has the correct answer_options" do

Loading…
Cancel
Save