From 4d0071d694088c653fb42d15813a20c76c6cbe9c Mon Sep 17 00:00:00 2001 From: Kat Date: Wed, 17 Jan 2024 09:03:43 +0000 Subject: [PATCH] Amend renewal question wording for 2024 --- app/models/form/lettings/questions/renewal.rb | 23 ++++++++++++++++--- .../form/lettings/questions/renewal_spec.rb | 22 ++++++++++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/app/models/form/lettings/questions/renewal.rb b/app/models/form/lettings/questions/renewal.rb index da8107c2a..418b64a37 100644 --- a/app/models/form/lettings/questions/renewal.rb +++ b/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 diff --git a/spec/models/form/lettings/questions/renewal_spec.rb b/spec/models/form/lettings/questions/renewal_spec.rb index 67f5c9d7a..9b01ea5cc 100644 --- a/spec/models/form/lettings/questions/renewal_spec.rb +++ b/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