Browse Source

Update answer options for 2025

CLDC-3844-add-rent-type-response
Kat 2 weeks ago
parent
commit
e7bddbd570
  1. 21
      app/models/form/lettings/questions/previous_let_type.rb
  2. 13
      app/models/form/lettings/questions/rent_type.rb
  3. 21
      spec/models/form/lettings/questions/previous_let_type_spec.rb
  4. 9
      spec/models/form/lettings/questions/rent_type_spec.rb

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

@ -4,7 +4,7 @@ class Form::Lettings::Questions::PreviousLetType < ::Form::Question
@id = "unitletas" @id = "unitletas"
@type = "radio" @type = "radio"
@check_answers_card_number = 0 @check_answers_card_number = 0
@answer_options = form.start_year_2024_or_later? ? ANSWER_OPTIONS_AFTER_2024 : ANSWER_OPTIONS @answer_options = answer_options
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end
@ -30,5 +30,24 @@ class Form::Lettings::Questions::PreviousLetType < ::Form::Question
"3" => { "value" => "Don’t know" }, "3" => { "value" => "Don’t know" },
}.freeze }.freeze
ANSWER_OPTIONS_AFTER_2025 = {
"1" => { "value" => "Social rent basis" },
"2" => { "value" => "Affordable rent basis" },
"5" => { "value" => "London Affordable Rent basis" },
"6" => { "value" => "Rent to Buy basis" },
"7" => { "value" => "London Living Rent basis" },
"8" => { "value" => "Another Intermediate Rent basis" },
"9" => { "value" => "Specified accommodation - exempt accommodation, manged properties, refuges and local authority hostels" },
"divider" => { "value" => true },
"3" => { "value" => "Don’t know" },
}.freeze
QUESTION_NUMBER_FROM_YEAR = { 2023 => 16, 2024 => 17 }.freeze QUESTION_NUMBER_FROM_YEAR = { 2023 => 16, 2024 => 17 }.freeze
def answer_options
return ANSWER_OPTIONS_AFTER_2025 if form.start_year_2025_or_later?
return ANSWER_OPTIONS_AFTER_2024 if form.start_year_2024_or_later?
ANSWER_OPTIONS
end
end end

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

@ -5,28 +5,33 @@ class Form::Lettings::Questions::RentType < ::Form::Question
@copy_key = "lettings.setup.rent_type.rent_type" @copy_key = "lettings.setup.rent_type.rent_type"
@type = "radio" @type = "radio"
@top_guidance_partial = "rent_type_definitions" @top_guidance_partial = "rent_type_definitions"
@answer_options = form.start_year_2024_or_later? ? ANSWER_OPTIONS_2024 : ANSWER_OPTIONS @answer_options = answer_options
@conditional_for = { "irproduct_other" => [5] } @conditional_for = { "irproduct_other" => [5] }
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present? @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present?
end end
ANSWER_OPTIONS = { ANSWER_OPTIONS = {
"0" => { "value" => "Social Rent" },
"1" => { "value" => "Affordable Rent" }, "1" => { "value" => "Affordable Rent" },
"2" => { "value" => "London Affordable Rent" }, "2" => { "value" => "London Affordable Rent" },
"4" => { "value" => "London Living Rent" },
"3" => { "value" => "Rent to Buy" }, "3" => { "value" => "Rent to Buy" },
"0" => { "value" => "Social Rent" }, "4" => { "value" => "London Living Rent" },
"5" => { "value" => "Other intermediate rent product" }, "5" => { "value" => "Other intermediate rent product" },
}.freeze }.freeze
ANSWER_OPTIONS_2024 = { ANSWER_OPTIONS_2025 = {
"0" => { "value" => "Social Rent" }, "0" => { "value" => "Social Rent" },
"1" => { "value" => "Affordable Rent" }, "1" => { "value" => "Affordable Rent" },
"2" => { "value" => "London Affordable Rent" }, "2" => { "value" => "London Affordable Rent" },
"3" => { "value" => "Rent to Buy" }, "3" => { "value" => "Rent to Buy" },
"4" => { "value" => "London Living Rent" }, "4" => { "value" => "London Living Rent" },
"5" => { "value" => "Other intermediate rent product" }, "5" => { "value" => "Other intermediate rent product" },
"6" => { "value" => "Specified accommodation - exempt accommodation, managed properties, refuges and local authority hostels" },
}.freeze }.freeze
QUESTION_NUMBER_FROM_YEAR = { 2023 => 6, 2024 => 8 }.freeze QUESTION_NUMBER_FROM_YEAR = { 2023 => 6, 2024 => 8 }.freeze
def answer_options
form.start_year_2025_or_later? ? ANSWER_OPTIONS_2025 : ANSWER_OPTIONS
end
end end

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

@ -9,6 +9,7 @@ RSpec.describe Form::Lettings::Questions::PreviousLetType, type: :model do
before do before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false) allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(form).to receive(:start_year_2025_or_later?).and_return(false)
allow(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
@ -60,4 +61,24 @@ RSpec.describe Form::Lettings::Questions::PreviousLetType, type: :model do
}) })
end end
end end
context "with collection year on or after 2025" do
before do
allow(form).to receive(:start_year_2025_or_later?).and_return(true)
end
it "has the correct answer options" do
expect(question.answer_options).to eq({
"1" => { "value" => "Social rent basis" },
"2" => { "value" => "Affordable rent basis" },
"5" => { "value" => "London Affordable Rent basis" },
"6" => { "value" => "Rent to Buy basis" },
"7" => { "value" => "London Living Rent basis" },
"8" => { "value" => "Another Intermediate Rent basis" },
"9" => { "value" => "Specified accommodation - exempt accommodation, manged properties, refuges and local authority hostels" },
"divider" => { "value" => true },
"3" => { "value" => "Don’t know" },
})
end
end
end end

9
spec/models/form/lettings/questions/rent_type_spec.rb

@ -12,7 +12,7 @@ RSpec.describe Form::Lettings::Questions::RentType, type: :model do
before do before do
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)
allow(form).to receive(:start_year_2024_or_later?).and_return(false) allow(form).to receive(:start_year_2025_or_later?).and_return(false)
end end
it "has correct page" do it "has correct page" do
@ -35,9 +35,9 @@ RSpec.describe Form::Lettings::Questions::RentType, type: :model do
expect(question.derived?(nil)).to be false expect(question.derived?(nil)).to be false
end end
context "when 2023" do context "when 2025" do
before do before do
allow(form).to receive(:start_year_2024_or_later?).and_return(false) allow(form).to receive(:start_year_2025_or_later?).and_return(true)
end end
it "has the correct answer_options" do it "has the correct answer_options" do
@ -48,6 +48,7 @@ RSpec.describe Form::Lettings::Questions::RentType, type: :model do
"3" => { "value" => "Rent to Buy" }, "3" => { "value" => "Rent to Buy" },
"0" => { "value" => "Social Rent" }, "0" => { "value" => "Social Rent" },
"5" => { "value" => "Other intermediate rent product" }, "5" => { "value" => "Other intermediate rent product" },
"6" => { "value" => "Specified accommodation - exempt accommodation, managed properties, refuges and local authority hostels" },
}) })
end end
@ -58,7 +59,7 @@ RSpec.describe Form::Lettings::Questions::RentType, type: :model do
context "when 2024" do context "when 2024" 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

Loading…
Cancel
Save