Browse Source

Amend renewal question wording for 2024

pull/2147/head
Kat 2 years ago
parent
commit
4d0071d694
  1. 23
      app/models/form/lettings/questions/renewal.rb
  2. 22
      spec/models/form/lettings/questions/renewal_spec.rb

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

@ -3,15 +3,32 @@ class Form::Lettings::Questions::Renewal < ::Form::Question
super
@id = "renewal"
@check_answer_label = "Property renewal"
@header = "Is this letting a renewal?"
@header = header_text
@type = "radio"
@answer_options = ANSWER_OPTIONS
@hint_text = "A renewal is a letting to the same tenant in the same property. If the property was previously being used as temporary accommodation, then answer 'no'"
@hint_text = hint_text
@question_number = 4
end
ANSWER_OPTIONS = {
"1" => { "value" => "Yes" },
"0" => { "value" => "No" },
}.freeze
}
.freeze
def header_text
if form.start_date && form.start_date.year >= 2024
"Is this letting a renewal of social housing to the same tenant in the same property?"
else
"Is this letting a renewal?"
end
end
def hint_text
if form.start_date && form.start_date.year >= 2024
"If the property was previously being used as temporary accommodation, then answer 'no'"
else
"A renewal is a letting to the same tenant in the same property. If the property was previously being used as temporary accommodation, then answer 'no'"
end
end
end

22
spec/models/form/lettings/questions/renewal_spec.rb

@ -6,6 +6,14 @@ RSpec.describe Form::Lettings::Questions::Renewal, type: :model do
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) }
before do
allow(form).to receive(:start_date).and_return(Time.zone.local(2023, 4, 1))
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)
@ -41,4 +49,18 @@ RSpec.describe Form::Lettings::Questions::Renewal, type: :model do
it "is not marked as derived" do
expect(question.derived?).to be false
end
context "with collection year on or after 2024" do
before do
allow(form).to receive(:start_date).and_return(Time.zone.local(2024, 4, 1))
end
it "has the correct header" do
expect(question.header).to eq("Is this letting a renewal of social housing to the same tenant in the same property?")
end
it "has the correct hint_text" do
expect(question.hint_text).to eq("If the property was previously being used as temporary accommodation, then answer 'no'")
end
end
end

Loading…
Cancel
Save