Browse Source

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
pull/1742/head
Aaron Spencer 2 years ago committed by GitHub
parent
commit
9662b14bde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      app/helpers/interruption_screen_helper.rb
  2. 25
      app/models/form/lettings/pages/max_rent_value_check.rb
  3. 11
      app/models/form/lettings/pages/min_rent_value_check.rb
  4. 15
      app/models/form/lettings/questions/max_rent_value_check.rb
  5. 3
      app/models/form/lettings/questions/min_rent_value_check.rb
  6. 4
      config/locales/en.yml
  7. 7
      spec/helpers/interruption_screen_helper_spec.rb
  8. 4
      spec/models/form/lettings/pages/max_rent_value_check_spec.rb
  9. 13
      spec/models/form/lettings/pages/min_rent_value_check_spec.rb
  10. 44
      spec/models/form/lettings/questions/max_rent_value_check_spec.rb
  11. 44
      spec/models/form/lettings/questions/min_rent_value_check_spec.rb
  12. 2
      spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

1
app/helpers/interruption_screen_helper.rb

@ -1,5 +1,6 @@
module InterruptionScreenHelper module InterruptionScreenHelper
def display_informative_text(informative_text, log) def display_informative_text(informative_text, log)
return informative_text if informative_text.is_a? String
return "" unless informative_text["arguments"] return "" unless informative_text["arguments"]
translation_params = {} translation_params = {}

25
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 }] @depends_on = [{ "rent_in_soft_max_range?" => true }]
@title_text = { @title_text = {
"translation" => "soft_validations.rent.outside_range_title", "translation" => "soft_validations.rent.outside_range_title",
"arguments" => [ "arguments" => [{
{ "key" => "brent",
"key" => "brent", "label" => true,
"label" => true, "i18n_template" => "brent",
"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",
},
],
} }
@informative_text = I18n.t("soft_validations.rent.informative_text", higher_or_lower: "higher")
@check_answers_card_number = check_answers_card_number @check_answers_card_number = check_answers_card_number
end end
def questions 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 end
def interruption_screen_question_ids def interruption_screen_question_ids

11
app/models/form/lettings/pages/min_rent_value_check.rb

@ -10,19 +10,12 @@ class Form::Lettings::Pages::MinRentValueCheck < ::Form::Page
"i18n_template" => "brent", "i18n_template" => "brent",
}], }],
} }
@informative_text = { @informative_text = I18n.t("soft_validations.rent.informative_text", higher_or_lower: "lower")
"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",
}],
}
@check_answers_card_number = check_answers_card_number @check_answers_card_number = check_answers_card_number
end end
def questions 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 end
def interruption_screen_question_ids def interruption_screen_question_ids

15
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

3
app/models/form/lettings/questions/rent_value_check.rb → 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:) def initialize(id, hsh, page, check_answers_card_number:)
super(id, hsh, page) super(id, hsh, page)
@id = "rent_value_check" @id = "rent_value_check"
@check_answer_label = "Total rent confirmation" @check_answer_label = "Total rent confirmation"
@header = "Are you sure this is correct?" @header = "Are you sure this is correct?"
@type = "interruption_screen" @type = "interruption_screen"
@hint_text = I18n.t("soft_validations.rent.hint_text", higher_or_lower: "lower")
@check_answers_card_number = check_answers_card_number @check_answers_card_number = check_answers_card_number
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@hidden_in_check_answers = { "depends_on" => [{ "rent_value_check" => 0 }, { "rent_value_check" => 1 }] } @hidden_in_check_answers = { "depends_on" => [{ "rent_value_check" => 0 }, { "rent_value_check" => 1 }] }

4
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?" 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: rent:
outside_range_title: "You told us the rent is %{brent}" 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}." informative_text: "This is %{higher_or_lower} than we would expect."
max_hint_text: "The maximum rent expected for this type of property in this local authority is %{soft_max_for_period}." hint_text: "Check the following:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the rent type is correct, for example affordable or social rent</li></ul>"
purchase_price: purchase_price:
title_text: "You told us the purchase price is %{value}" title_text: "You told us the purchase price is %{value}"
hint_text: "This is %{higher_or_lower} than we would expect" hint_text: "This is %{higher_or_lower} than we would expect"

7
spec/helpers/interruption_screen_helper_spec.rb

@ -163,6 +163,13 @@ RSpec.describe InterruptionScreenHelper do
expect(display_informative_text(informative_text_hash, lettings_log)).to eq("You said this: £12,345.00") expect(display_informative_text(informative_text_hash, lettings_log)).to eq("You said this: £12,345.00")
end end
end end
context "when a string given" do
it "returns the string" do
test_string = "some words"
expect(display_informative_text(test_string, lettings_log)).to eq(test_string)
end
end
end end
describe "display_title_text" do describe "display_title_text" do

4
spec/models/form/lettings/pages/max_rent_value_check_spec.rb

@ -31,10 +31,6 @@ RSpec.describe Form::Lettings::Pages::MaxRentValueCheck, type: :model do
expect(page.title_text).to eq({ "arguments" => [{ "i18n_template" => "brent", "key" => "brent", "label" => true }], "translation" => "soft_validations.rent.outside_range_title" }) expect(page.title_text).to eq({ "arguments" => [{ "i18n_template" => "brent", "key" => "brent", "label" => true }], "translation" => "soft_validations.rent.outside_range_title" })
end end
it "has the correct informative_text" do
expect(page.informative_text).to eq({ "arguments" => [{ "arguments_for_key" => "soft_max_for_period", "i18n_template" => "soft_max_for_period", "key" => "field_formatted_as_currency" }], "translation" => "soft_validations.rent.max_hint_text" })
end
it "has the correct interruption_screen_question_ids" do it "has the correct interruption_screen_question_ids" do
expect(page.interruption_screen_question_ids).to eq(%w[brent startdate uprn postcode_full la beds rent_type needstype]) expect(page.interruption_screen_question_ids).to eq(%w[brent startdate uprn postcode_full la beds rent_type needstype])
end end

13
spec/models/form/lettings/pages/min_rent_value_check_spec.rb

@ -40,19 +40,6 @@ RSpec.describe Form::Lettings::Pages::MinRentValueCheck, type: :model do
}) })
end end
it "has the correct informative_text" do
expect(page.informative_text).to eq({
"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",
},
],
})
end
it "has the correct interruption_screen_question_ids" do it "has the correct interruption_screen_question_ids" do
expect(page.interruption_screen_question_ids).to eq(%w[brent startdate uprn postcode_full la beds rent_type needstype]) expect(page.interruption_screen_question_ids).to eq(%w[brent startdate uprn postcode_full la beds rent_type needstype])
end end

44
spec/models/form/lettings/questions/max_rent_value_check_spec.rb

@ -0,0 +1,44 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::MaxRentValueCheck, type: :model do
subject(:question) { described_class.new(nil, question_definition, page, check_answers_card_number:) }
let(:question_definition) { nil }
let(:check_answers_card_number) { nil }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct id" do
expect(question.id).to eq("rent_value_check")
end
it "has the correct header" do
expect(question.header).to eq("Are you sure this is correct?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Total rent confirmation")
end
it "has the correct type" do
expect(question.type).to eq("interruption_screen")
end
it "has the correct hint" do
expect(question.hint_text).to eq("Check the following:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the rent type is correct, for example affordable or social rent</li></ul>")
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
})
end
it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers).to eq({ "depends_on" => [{ "rent_value_check" => 0 }, { "rent_value_check" => 1 }] })
end
end

44
spec/models/form/lettings/questions/min_rent_value_check_spec.rb

@ -0,0 +1,44 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::MinRentValueCheck, type: :model do
subject(:question) { described_class.new(nil, question_definition, page, check_answers_card_number:) }
let(:question_definition) { nil }
let(:check_answers_card_number) { nil }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct id" do
expect(question.id).to eq("rent_value_check")
end
it "has the correct header" do
expect(question.header).to eq("Are you sure this is correct?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Total rent confirmation")
end
it "has the correct type" do
expect(question.type).to eq("interruption_screen")
end
it "has the correct hint" do
expect(question.hint_text).to eq("Check the following:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the rent type is correct, for example affordable or social rent</li></ul>")
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
})
end
it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers).to eq({ "depends_on" => [{ "rent_value_check" => 0 }, { "rent_value_check" => 1 }] })
end
end

2
spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

@ -1098,7 +1098,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
it "populates with correct error message" do it "populates with correct error message" do
expect(parser.errors.where(:field_128, category: :soft_validation).count).to be(1) expect(parser.errors.where(:field_128, category: :soft_validation).count).to be(1)
expect(parser.errors.where(:field_128, category: :soft_validation).first.message).to eql("You told us the rent is £120.00 every week. The maximum rent expected for this type of property in this local authority is ££118.85 every week.") expect(parser.errors.where(:field_128, category: :soft_validation).first.message).to eql("You told us the rent is £120.00 every week. This is higher than we would expect.")
end end
end end
end end

Loading…
Cancel
Save