Browse Source

CLDC-3131 Amend previous rent basis answer options and hint for 2024 (#2148)

* Amend previous let type answer options and hint

* Update variable name
pull/2170/head
kosiakkatrina 11 months ago committed by GitHub
parent
commit
ed72c91a12
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 15
      app/models/form/lettings/questions/previous_let_type.rb
  2. 31
      spec/models/form/lettings/questions/previous_let_type_spec.rb

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

@ -6,8 +6,8 @@ class Form::Lettings::Questions::PreviousLetType < ::Form::Question
@header = "What type was the property most recently let as?"
@type = "radio"
@check_answers_card_number = 0
@hint_text = ""
@answer_options = ANSWER_OPTIONS
@hint_text = form.start_year_after_2024? ? "This is the rent type of the previous tenancy in this property." : ""
@answer_options = form.start_year_after_2024? ? ANSWER_OPTIONS_AFTER_2024 : ANSWER_OPTIONS
@question_number = 16
end
@ -21,4 +21,15 @@ class Form::Lettings::Questions::PreviousLetType < ::Form::Question
"divider" => { "value" => true },
"3" => { "value" => "Don’t know" },
}.freeze
ANSWER_OPTIONS_AFTER_2024 = {
"1" => { "value" => "Social rent basis" },
"2" => { "value" => "Affordable rent basis" },
"5" => { "value" => "London Affordable Rent basis" },
"6" => { "value" => "Rent to Buy basis" },
"7" => { "value" => "London Living Rent basis" },
"8" => { "value" => "Another Intermediate Rent basis" },
"divider" => { "value" => true },
"3" => { "value" => "Don’t know" },
}.freeze
end

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

@ -4,6 +4,14 @@ RSpec.describe Form::Lettings::Questions::PreviousLetType, type: :model do
subject(:question) { described_class.new(nil, nil, page) }
let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form) }
before do
allow(form).to receive(:start_year_after_2024?).and_return(false)
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end
it "has correct page" do
expect(question.page).to eq page
@ -45,4 +53,27 @@ RSpec.describe Form::Lettings::Questions::PreviousLetType, type: :model do
"3" => { "value" => "Don’t know" },
})
end
context "with collection year on or after 2024" do
before do
allow(form).to receive(:start_year_after_2024?).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" },
"divider" => { "value" => true },
"3" => { "value" => "Don’t know" },
})
end
it "has the correct hint_text" do
expect(question.hint_text).to eq("This is the rent type of the previous tenancy in this property.")
end
end
end

Loading…
Cancel
Save