From d9a185f21f9831f1ca8e366c20c68aa8a912ad60 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Mon, 18 Dec 2023 13:54:31 +0100 Subject: [PATCH] Set different hint texts for tenancy length (#2096) --- app/models/form/lettings/pages/tenancy_length.rb | 2 +- .../pages/tenancy_length_affordable_rent.rb | 11 +++++++++++ .../pages/tenancy_length_intermediate_rent.rb | 11 +++++++++++ .../form/lettings/questions/tenancy_length.rb | 2 +- .../questions/tenancy_length_affordable_rent.rb | 16 ++++++++++++++++ .../tenancy_length_intermediate_rent.rb | 16 ++++++++++++++++ .../lettings/subsections/tenancy_information.rb | 2 ++ app/models/lettings_log.rb | 4 ++++ .../form/lettings/pages/tenancy_length_spec.rb | 2 +- .../lettings/questions/tenancy_length_spec.rb | 2 +- .../subsections/tenancy_information_spec.rb | 2 +- 11 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 app/models/form/lettings/pages/tenancy_length_affordable_rent.rb create mode 100644 app/models/form/lettings/pages/tenancy_length_intermediate_rent.rb create mode 100644 app/models/form/lettings/questions/tenancy_length_affordable_rent.rb create mode 100644 app/models/form/lettings/questions/tenancy_length_intermediate_rent.rb diff --git a/app/models/form/lettings/pages/tenancy_length.rb b/app/models/form/lettings/pages/tenancy_length.rb index cb533dcf9..006cd8e42 100644 --- a/app/models/form/lettings/pages/tenancy_length.rb +++ b/app/models/form/lettings/pages/tenancy_length.rb @@ -2,7 +2,7 @@ class Form::Lettings::Pages::TenancyLength < ::Form::Page def initialize(id, hsh, subsection) super @id = "tenancy_length" - @depends_on = [{ "tenancy_type_fixed_term?" => true }] + @depends_on = [{ "tenancy_type_fixed_term?" => true, "needstype" => 2 }] end def questions diff --git a/app/models/form/lettings/pages/tenancy_length_affordable_rent.rb b/app/models/form/lettings/pages/tenancy_length_affordable_rent.rb new file mode 100644 index 000000000..aa88d81f9 --- /dev/null +++ b/app/models/form/lettings/pages/tenancy_length_affordable_rent.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::TenancyLengthAffordableRent < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "tenancy_length_affordable_rent" + @depends_on = [{ "tenancy_type_fixed_term?" => true, "affordable_or_social_rent?" => true, "needstype" => 1 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::TenancyLengthAffordableRent.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/tenancy_length_intermediate_rent.rb b/app/models/form/lettings/pages/tenancy_length_intermediate_rent.rb new file mode 100644 index 000000000..070d0abe1 --- /dev/null +++ b/app/models/form/lettings/pages/tenancy_length_intermediate_rent.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::TenancyLengthIntermediateRent < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "tenancy_length_intermediate_rent" + @depends_on = [{ "tenancy_type_fixed_term?" => true, "affordable_or_social_rent?" => false, "needstype" => 1 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::TenancyLengthIntermediateRent.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/questions/tenancy_length.rb b/app/models/form/lettings/questions/tenancy_length.rb index 90b34aa62..7dd572560 100644 --- a/app/models/form/lettings/questions/tenancy_length.rb +++ b/app/models/form/lettings/questions/tenancy_length.rb @@ -9,7 +9,7 @@ class Form::Lettings::Questions::TenancyLength < ::Form::Question @check_answers_card_number = 0 @max = 150 @min = 0 - @hint_text = "Don’t include the starter or introductory period." + @hint_text = "Do not include the starter or introductory period." @step = 1 @question_number = 28 end diff --git a/app/models/form/lettings/questions/tenancy_length_affordable_rent.rb b/app/models/form/lettings/questions/tenancy_length_affordable_rent.rb new file mode 100644 index 000000000..6918ce6a8 --- /dev/null +++ b/app/models/form/lettings/questions/tenancy_length_affordable_rent.rb @@ -0,0 +1,16 @@ +class Form::Lettings::Questions::TenancyLengthAffordableRent < ::Form::Question + def initialize(id, hsh, page) + super + @id = "tenancylength" + @check_answer_label = "Length of fixed-term tenancy" + @header = "What is the length of the fixed-term tenancy to the nearest year?" + @type = "numeric" + @width = 2 + @check_answers_card_number = 0 + @max = 150 + @min = 0 + @hint_text = "Do not include the starter or introductory period.
The minimum period is 2 years for social or affordable rent general needs logs and you do not need a log for shorter tenancies." + @step = 1 + @question_number = 28 + end +end diff --git a/app/models/form/lettings/questions/tenancy_length_intermediate_rent.rb b/app/models/form/lettings/questions/tenancy_length_intermediate_rent.rb new file mode 100644 index 000000000..c62f6330c --- /dev/null +++ b/app/models/form/lettings/questions/tenancy_length_intermediate_rent.rb @@ -0,0 +1,16 @@ +class Form::Lettings::Questions::TenancyLengthIntermediateRent < ::Form::Question + def initialize(id, hsh, page) + super + @id = "tenancylength" + @check_answer_label = "Length of fixed-term tenancy" + @header = "What is the length of the fixed-term tenancy to the nearest year?" + @type = "numeric" + @width = 2 + @check_answers_card_number = 0 + @max = 150 + @min = 0 + @hint_text = "Do not include the starter or introductory period.
The minimum period is 1 year for intermediate rent general needs logs and you do not need a log for shorter tenancies." + @step = 1 + @question_number = 28 + end +end diff --git a/app/models/form/lettings/subsections/tenancy_information.rb b/app/models/form/lettings/subsections/tenancy_information.rb index be8e4fdce..f45ce3baa 100644 --- a/app/models/form/lettings/subsections/tenancy_information.rb +++ b/app/models/form/lettings/subsections/tenancy_information.rb @@ -13,6 +13,8 @@ class Form::Lettings::Subsections::TenancyInformation < ::Form::Subsection Form::Lettings::Pages::TenancyType.new(nil, nil, self), Form::Lettings::Pages::StarterTenancyType.new(nil, nil, self), Form::Lettings::Pages::TenancyLength.new(nil, nil, self), + Form::Lettings::Pages::TenancyLengthAffordableRent.new(nil, nil, self), + Form::Lettings::Pages::TenancyLengthIntermediateRent.new(nil, nil, self), Form::Lettings::Pages::ShelteredAccommodation.new(nil, nil, self), ].compact end diff --git a/app/models/lettings_log.rb b/app/models/lettings_log.rb index d86f20424..3eda732d1 100644 --- a/app/models/lettings_log.rb +++ b/app/models/lettings_log.rb @@ -627,6 +627,10 @@ class LettingsLog < Log letting_allocation_unknown end + def affordable_or_social_rent? + renttype == 1 || renttype == 2 + end + private def reset_invalid_unresolved_log_fields! diff --git a/spec/models/form/lettings/pages/tenancy_length_spec.rb b/spec/models/form/lettings/pages/tenancy_length_spec.rb index d4ea920ae..b3c949a32 100644 --- a/spec/models/form/lettings/pages/tenancy_length_spec.rb +++ b/spec/models/form/lettings/pages/tenancy_length_spec.rb @@ -26,6 +26,6 @@ RSpec.describe Form::Lettings::Pages::TenancyLength, type: :model do end it "has the correct depends_on" do - expect(page.depends_on).to eq [{ "tenancy_type_fixed_term?" => true }] + expect(page.depends_on).to eq [{ "tenancy_type_fixed_term?" => true, "needstype" => 2 }] end end diff --git a/spec/models/form/lettings/questions/tenancy_length_spec.rb b/spec/models/form/lettings/questions/tenancy_length_spec.rb index 8eea52a81..0a83d0baa 100644 --- a/spec/models/form/lettings/questions/tenancy_length_spec.rb +++ b/spec/models/form/lettings/questions/tenancy_length_spec.rb @@ -26,7 +26,7 @@ RSpec.describe Form::Lettings::Questions::TenancyLength, type: :model do end it "has the correct hint_text" do - expect(question.hint_text).to eq("Don’t include the starter or introductory period.") + expect(question.hint_text).to eq("Do not include the starter or introductory period.") end it "has the correct minimum and maximum" do diff --git a/spec/models/form/lettings/subsections/tenancy_information_spec.rb b/spec/models/form/lettings/subsections/tenancy_information_spec.rb index 475ea209c..45a1d28b3 100644 --- a/spec/models/form/lettings/subsections/tenancy_information_spec.rb +++ b/spec/models/form/lettings/subsections/tenancy_information_spec.rb @@ -13,7 +13,7 @@ RSpec.describe Form::Lettings::Subsections::TenancyInformation, type: :model do it "has correct pages" do expect(tenancy_information.pages.map(&:id)).to eq( - %w[joint starter_tenancy tenancy_type starter_tenancy_type tenancy_length sheltered_accommodation], + %w[joint starter_tenancy tenancy_type starter_tenancy_type tenancy_length tenancy_length_affordable_rent tenancy_length_intermediate_rent sheltered_accommodation], ) end