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. 42
      app/models/form/lettings/questions/referral_general_needs.rb
  2. 42
      app/models/form/lettings/questions/referral_supported_housing.rb
  3. 48
      app/models/form/lettings/questions/referral_supported_housing_prp.rb
  4. 43
      app/models/form/lettings/questions/rsnvac.rb
  5. 26
      app/models/form/lettings/questions/starter_tenancy_type.rb
  6. 26
      app/models/form/lettings/questions/tenancy_type.rb
  7. 7
      app/models/form/lettings/questions/uprn_confirmation.rb
  8. 15
      app/models/form/lettings/questions/waityear.rb
  9. 36
      spec/models/form/lettings/questions/referral_general_needs_spec.rb
  10. 38
      spec/models/form/lettings/questions/referral_supported_housing_prp_spec.rb
  11. 36
      spec/models/form/lettings/questions/referral_supported_housing_spec.rb
  12. 64
      spec/models/form/lettings/questions/rsnvac_spec.rb
  13. 52
      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

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

@ -10,7 +10,6 @@ class Form::Lettings::Questions::ReferralGeneralNeeds < ::Form::Question
end
def answer_options
if form.start_year_2024_or_later?
{
"1" => {
"value" => "Internal transfer",
@ -50,47 +49,6 @@ class Form::Lettings::Questions::ReferralGeneralNeeds < ::Form::Question
"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
end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 85, 2024 => 84, 2025 => 84 }.freeze

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

@ -10,7 +10,6 @@ class Form::Lettings::Questions::ReferralSupportedHousing < ::Form::Question
end
def answer_options
if form.start_year_2024_or_later?
{
"1" => {
"value" => "Internal transfer",
@ -50,47 +49,6 @@ class Form::Lettings::Questions::ReferralSupportedHousing < ::Form::Question
"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
end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 85, 2024 => 84, 2025 => 84 }.freeze

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

@ -10,7 +10,6 @@ class Form::Lettings::Questions::ReferralSupportedHousingPrp < ::Form::Question
end
def answer_options
if form.start_year_2024_or_later?
{
"1" => {
"value" => "Internal transfer",
@ -56,53 +55,6 @@ class Form::Lettings::Questions::ReferralSupportedHousingPrp < ::Form::Question
"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
end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 85, 2024 => 84, 2025 => 84 }.freeze

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

@ -7,7 +7,6 @@ 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",
@ -54,48 +53,6 @@ class Form::Lettings::Questions::Rsnvac < ::Form::Question
"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
end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 17, 2024 => 18, 2025 => 15, 2026 => 15 }.freeze

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

@ -10,7 +10,6 @@ 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",
@ -38,31 +37,6 @@ class Form::Lettings::Questions::StarterTenancyType < ::Form::Question
"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
end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 27, 2024 => 27, 2025 => 28, 2026 => 27 }.freeze

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

@ -10,7 +10,6 @@ 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",
@ -38,31 +37,6 @@ class Form::Lettings::Questions::TenancyType < ::Form::Question
"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
end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 27, 2024 => 27, 2025 => 28, 2026 => 27 }.freeze

7
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
end
def notification_banner(log = nil)

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

@ -23,8 +23,7 @@ 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" },
@ -37,17 +36,5 @@ class Form::Lettings::Questions::Waityear < ::Form::Question
}.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" },
"divider" => { "value" => true },
"6" => { "value" => "Don’t know" },
}.freeze
end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 76, 2024 => 75, 2025 => 75, 2026 => 82 }.freeze
end

36
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,36 +36,6 @@ 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." },
@ -86,4 +57,3 @@ RSpec.describe Form::Lettings::Questions::ReferralGeneralNeeds, type: :model do
expect(question.question_number).to eq(84)
end
end
end

38
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,38 +36,6 @@ 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." },
@ -90,4 +59,3 @@ RSpec.describe Form::Lettings::Questions::ReferralSupportedHousingPrp, type: :mo
expect(question.question_number).to eq(84)
end
end
end

36
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,36 +36,6 @@ 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." },
@ -86,4 +57,3 @@ RSpec.describe Form::Lettings::Questions::ReferralSupportedHousing, type: :model
expect(question.question_number).to eq(84)
end
end
end

64
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,58 +32,6 @@ 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
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" => {
@ -132,6 +81,9 @@ RSpec.describe Form::Lettings::Questions::Rsnvac, type: :model do
})
end
context "with 2024/25 form" do
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
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

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

@ -1,60 +1,21 @@
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",
},
},
)
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(
{
@ -87,6 +48,9 @@ RSpec.describe Form::Lettings::Questions::StarterTenancyType, type: :model do
)
end
context "with 2024/25 form" do
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
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