From ed72c91a12c5d1d78ea0d6e89aeffc263c66e7dc Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Thu, 25 Jan 2024 11:42:37 +0000 Subject: [PATCH] CLDC-3131 Amend previous rent basis answer options and hint for 2024 (#2148) * Amend previous let type answer options and hint * Update variable name --- .../lettings/questions/previous_let_type.rb | 15 +++++++-- .../questions/previous_let_type_spec.rb | 31 +++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/app/models/form/lettings/questions/previous_let_type.rb b/app/models/form/lettings/questions/previous_let_type.rb index 6c9947743..6ce55da42 100644 --- a/app/models/form/lettings/questions/previous_let_type.rb +++ b/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 diff --git a/spec/models/form/lettings/questions/previous_let_type_spec.rb b/spec/models/form/lettings/questions/previous_let_type_spec.rb index b18bbc88a..9f43f0aff 100644 --- a/spec/models/form/lettings/questions/previous_let_type_spec.rb +++ b/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