From 9662b14bdefb2a112e096a9ef1e38d110781e0af Mon Sep 17 00:00:00 2001 From: Aaron Spencer <62190777+Airk0n@users.noreply.github.com> Date: Thu, 29 Jun 2023 16:57:46 +0100 Subject: [PATCH] CLDC 2439: apply 22/23 rent range soft validation to 23/24 (#1718) * CLDC-2439: min and max rent value check questions created * CLDC-2439: Informative removed, check pages fixed. * CLDC-2439: removed informative info tests and rent value check * CLDC-2439: fixed informative missing test failure * CLDC-2439: Text moved to en.yml * CLDC-2439: tests added, copy moved to en.yml * CLDC-2439: tests added, copy moved to en.yml * CLDC-2439: content change for bulk upload errors WIP * CLDC-2439: informative rendering change, content change, test updated * CLDC-2439: failing test fix. * CLDC-2439: display_informative_text test added for strings * CLDC-2439: string as var in test --- app/helpers/interruption_screen_helper.rb | 1 + .../lettings/pages/max_rent_value_check.rb | 25 +++-------- .../lettings/pages/min_rent_value_check.rb | 11 +---- .../questions/max_rent_value_check.rb | 15 +++++++ ...value_check.rb => min_rent_value_check.rb} | 3 +- config/locales/en.yml | 4 +- .../interruption_screen_helper_spec.rb | 7 +++ .../pages/max_rent_value_check_spec.rb | 4 -- .../pages/min_rent_value_check_spec.rb | 13 ------ .../questions/max_rent_value_check_spec.rb | 44 +++++++++++++++++++ .../questions/min_rent_value_check_spec.rb | 44 +++++++++++++++++++ .../lettings/year2023/row_parser_spec.rb | 2 +- 12 files changed, 125 insertions(+), 48 deletions(-) create mode 100644 app/models/form/lettings/questions/max_rent_value_check.rb rename app/models/form/lettings/questions/{rent_value_check.rb => min_rent_value_check.rb} (77%) create mode 100644 spec/models/form/lettings/questions/max_rent_value_check_spec.rb create mode 100644 spec/models/form/lettings/questions/min_rent_value_check_spec.rb diff --git a/app/helpers/interruption_screen_helper.rb b/app/helpers/interruption_screen_helper.rb index fc75f6f59..b28c7eaa9 100644 --- a/app/helpers/interruption_screen_helper.rb +++ b/app/helpers/interruption_screen_helper.rb @@ -1,5 +1,6 @@ module InterruptionScreenHelper def display_informative_text(informative_text, log) + return informative_text if informative_text.is_a? String return "" unless informative_text["arguments"] translation_params = {} diff --git a/app/models/form/lettings/pages/max_rent_value_check.rb b/app/models/form/lettings/pages/max_rent_value_check.rb index ffb90f035..82aff8481 100644 --- a/app/models/form/lettings/pages/max_rent_value_check.rb +++ b/app/models/form/lettings/pages/max_rent_value_check.rb @@ -4,29 +4,18 @@ class Form::Lettings::Pages::MaxRentValueCheck < ::Form::Page @depends_on = [{ "rent_in_soft_max_range?" => true }] @title_text = { "translation" => "soft_validations.rent.outside_range_title", - "arguments" => [ - { - "key" => "brent", - "label" => true, - "i18n_template" => "brent", - }, - ], - } - @informative_text = { - "translation" => "soft_validations.rent.max_hint_text", - "arguments" => [ - { - "key" => "field_formatted_as_currency", - "arguments_for_key" => "soft_max_for_period", - "i18n_template" => "soft_max_for_period", - }, - ], + "arguments" => [{ + "key" => "brent", + "label" => true, + "i18n_template" => "brent", + }], } + @informative_text = I18n.t("soft_validations.rent.informative_text", higher_or_lower: "higher") @check_answers_card_number = check_answers_card_number end def questions - @questions ||= [Form::Lettings::Questions::RentValueCheck.new(nil, nil, self, check_answers_card_number: @check_answers_card_number)] + @questions ||= [Form::Lettings::Questions::MaxRentValueCheck.new(nil, nil, self, check_answers_card_number: @check_answers_card_number)] end def interruption_screen_question_ids diff --git a/app/models/form/lettings/pages/min_rent_value_check.rb b/app/models/form/lettings/pages/min_rent_value_check.rb index f66bc5a7b..b2bae4e8e 100644 --- a/app/models/form/lettings/pages/min_rent_value_check.rb +++ b/app/models/form/lettings/pages/min_rent_value_check.rb @@ -10,19 +10,12 @@ class Form::Lettings::Pages::MinRentValueCheck < ::Form::Page "i18n_template" => "brent", }], } - @informative_text = { - "translation" => "soft_validations.rent.min_hint_text", - "arguments" => [{ - "key" => "field_formatted_as_currency", - "arguments_for_key" => "soft_min_for_period", - "i18n_template" => "soft_min_for_period", - }], - } + @informative_text = I18n.t("soft_validations.rent.informative_text", higher_or_lower: "lower") @check_answers_card_number = check_answers_card_number end def questions - @questions ||= [Form::Lettings::Questions::RentValueCheck.new(nil, nil, self, check_answers_card_number: @check_answers_card_number)] + @questions ||= [Form::Lettings::Questions::MinRentValueCheck.new(nil, nil, self, check_answers_card_number: @check_answers_card_number)] end def interruption_screen_question_ids diff --git a/app/models/form/lettings/questions/max_rent_value_check.rb b/app/models/form/lettings/questions/max_rent_value_check.rb new file mode 100644 index 000000000..6936e9e36 --- /dev/null +++ b/app/models/form/lettings/questions/max_rent_value_check.rb @@ -0,0 +1,15 @@ +class Form::Lettings::Questions::MaxRentValueCheck < ::Form::Question + def initialize(id, hsh, page, check_answers_card_number:) + super(id, hsh, page) + @id = "rent_value_check" + @check_answer_label = "Total rent confirmation" + @header = "Are you sure this is correct?" + @type = "interruption_screen" + @hint_text = I18n.t("soft_validations.rent.hint_text", higher_or_lower: "higher") + @check_answers_card_number = check_answers_card_number + @answer_options = ANSWER_OPTIONS + @hidden_in_check_answers = { "depends_on" => [{ "rent_value_check" => 0 }, { "rent_value_check" => 1 }] } + end + + ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze +end diff --git a/app/models/form/lettings/questions/rent_value_check.rb b/app/models/form/lettings/questions/min_rent_value_check.rb similarity index 77% rename from app/models/form/lettings/questions/rent_value_check.rb rename to app/models/form/lettings/questions/min_rent_value_check.rb index 6bca43e30..ad4111c61 100644 --- a/app/models/form/lettings/questions/rent_value_check.rb +++ b/app/models/form/lettings/questions/min_rent_value_check.rb @@ -1,10 +1,11 @@ -class Form::Lettings::Questions::RentValueCheck < ::Form::Question +class Form::Lettings::Questions::MinRentValueCheck < ::Form::Question def initialize(id, hsh, page, check_answers_card_number:) super(id, hsh, page) @id = "rent_value_check" @check_answer_label = "Total rent confirmation" @header = "Are you sure this is correct?" @type = "interruption_screen" + @hint_text = I18n.t("soft_validations.rent.hint_text", higher_or_lower: "lower") @check_answers_card_number = check_answers_card_number @answer_options = ANSWER_OPTIONS @hidden_in_check_answers = { "depends_on" => [{ "rent_value_check" => 0 }, { "rent_value_check" => 1 }] } diff --git a/config/locales/en.yml b/config/locales/en.yml index 49aa2d6f1..1365fda3d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -595,8 +595,8 @@ en: over_soft_max_for_la_combined: "You told us the combined income of this household is %{combined_income}. This seems high. Are you sure this is correct?" rent: outside_range_title: "You told us the rent is %{brent}" - min_hint_text: "The minimum rent expected for this type of property in this local authority is %{soft_min_for_period}." - max_hint_text: "The maximum rent expected for this type of property in this local authority is %{soft_max_for_period}." + informative_text: "This is %{higher_or_lower} than we would expect." + hint_text: "Check the following: