From 40a077c36e4063fa71ea498d1480e78a4b34a75f Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Fri, 1 Nov 2024 15:12:22 +0000 Subject: [PATCH] Refactor, remove one level of keys --- .../validations/household_validations.rb | 12 +++++----- .../validations/lettings/household.en.yml | 23 +++++++------------ .../validations/household_validations_spec.rb | 12 +++++----- 3 files changed, 20 insertions(+), 27 deletions(-) diff --git a/app/models/validations/household_validations.rb b/app/models/validations/household_validations.rb index 619d6499b..43786eea5 100644 --- a/app/models/validations/household_validations.rb +++ b/app/models/validations/household_validations.rb @@ -194,12 +194,12 @@ module Validations::HouseholdValidations return unless record.layear && record.la && record.prevloc && record.collection_start_year if record.la == record.prevloc && record.layear == 1 && record.collection_start_year >= 2023 - record.errors.add :layear, :renewal_just_moved, message: I18n.t("validations.lettings.household.layear.same_la_just_moved_to_area.current_la") - record.errors.add :la, :renewal_just_moved, message: I18n.t("validations.lettings.household.la.same_la_just_moved_to_area.current_la") - record.errors.add :postcode_full, :renewal_just_moved, message: I18n.t("validations.lettings.household.postcode_full.same_la_just_moved_to_area.current_la") - record.errors.add :uprn, :renewal_just_moved, message: I18n.t("validations.lettings.household.uprn.same_la_just_moved_to_area.current_la") - record.errors.add :ppostcode_full, :renewal_just_moved, message: I18n.t("validations.lettings.household.ppostcode_full.same_la_just_moved_to_area.previous_la") - record.errors.add :prevloc, :renewal_just_moved, message: I18n.t("validations.lettings.household.prevloc.same_la_just_moved_to_area.previous_la") + record.errors.add :layear, :renewal_just_moved, message: I18n.t("validations.lettings.household.layear.same_la_just_moved_to_area") + record.errors.add :la, :renewal_just_moved, message: I18n.t("validations.lettings.household.la.same_la_just_moved_to_area") + record.errors.add :postcode_full, :renewal_just_moved, message: I18n.t("validations.lettings.household.postcode_full.same_la_just_moved_to_area") + record.errors.add :uprn, :renewal_just_moved, message: I18n.t("validations.lettings.household.uprn.same_la_just_moved_to_area") + record.errors.add :ppostcode_full, :renewal_just_moved, message: I18n.t("validations.lettings.household.ppostcode_full.same_la_just_moved_to_area") + record.errors.add :prevloc, :renewal_just_moved, message: I18n.t("validations.lettings.household.prevloc.same_la_just_moved_to_area") end end diff --git a/config/locales/validations/lettings/household.en.yml b/config/locales/validations/lettings/household.en.yml index f60622540..ecfe02ee4 100644 --- a/config/locales/validations/lettings/household.en.yml +++ b/config/locales/validations/lettings/household.en.yml @@ -36,33 +36,26 @@ en: prevloc: previous_la_known: "Enter name of local authority." - same_la_just_moved_to_area: - previous_la: 'The local authority of the previous property should not be the same as the current local authority, as you told us they had just moved to the local authority area. Check your answers are correct.' + same_la_just_moved_to_area: "The local authority of the previous property should not be the same as the current local authority, as you told us they had just moved to the local authority area. Check your answers are correct." renewal: - renewal_just_moved_to_area: 'This letting cannot be a renewal if the household has just moved to the local authority area' + renewal_just_moved_to_area: "This letting cannot be a renewal if the household has just moved to the local authority area" layear: - renewal_just_moved_to_area: 'The household cannot have just moved to the local authority area if this letting is a renewal' - same_la_just_moved_to_area: - current_la: 'You told us this tenant previously lived in this local authority. Check your answers are correct.' + renewal_just_moved_to_area: "The household cannot have just moved to the local authority area if this letting is a renewal" + same_la_just_moved_to_area: "You told us this tenant previously lived in this local authority. Check your answers are correct." la: - same_la_just_moved_to_area: - current_la: 'You told us the tenant had just moved into the local authority, but this location is in the same local authority. Check your answers are correct' + same_la_just_moved_to_area: "You told us the tenant had just moved into the local authority, but this location is in the same local authority. Check your answers are correct" postcode_full: - same_la_just_moved_to_area: - current_la: 'You told us the tenant had just moved into the local authority, but this location is in the same local authority. Check your answers are correct' - previous_la: 'The local authority of the previous property should not be the same as the current local authority, as you told us they had just moved to the local authority area. Check your answers are correct.' + same_la_just_moved_to_area: "You told us the tenant had just moved into the local authority, but this location is in the same local authority. Check your answers are correct" ppostcode_full: - same_la_just_moved_to_area: - previous_la: 'The local authority of the previous property should not be the same as the current local authority, as you told us they had just moved to the local authority area. Check your answers are correct.' + same_la_just_moved_to_area: "The local authority of the previous property should not be the same as the current local authority, as you told us they had just moved to the local authority area. Check your answers are correct." uprn: - same_la_just_moved_to_area: - current_la: 'You told us the tenant had just moved into the local authority, but this location is in the same local authority. Check your answers are correct' + same_la_just_moved_to_area: "You told us the tenant had just moved into the local authority, but this location is in the same local authority. Check your answers are correct" age: child_under_16_relat: "Answer cannot be under 16 as person %{person_num}'s relationship to the lead tenant is ‘partner’." diff --git a/spec/models/validations/household_validations_spec.rb b/spec/models/validations/household_validations_spec.rb index 2d3c325b6..9ffc7c0f3 100644 --- a/spec/models/validations/household_validations_spec.rb +++ b/spec/models/validations/household_validations_spec.rb @@ -668,17 +668,17 @@ RSpec.describe Validations::HouseholdValidations do record.startdate = Time.zone.now household_validator.validate_layear_and_prevloc(record) expect(record.errors["layear"]) - .to include(match I18n.t("validations.lettings.household.layear.same_la_just_moved_to_area.current_la")) + .to include(match I18n.t("validations.lettings.household.layear.same_la_just_moved_to_area")) expect(record.errors["prevloc"]) - .to include(match I18n.t("validations.lettings.household.prevloc.same_la_just_moved_to_area.previous_la")) + .to include(match I18n.t("validations.lettings.household.prevloc.same_la_just_moved_to_area")) expect(record.errors["ppostcode_full"]) - .to include(match I18n.t("validations.lettings.household.ppostcode_full.same_la_just_moved_to_area.previous_la")) + .to include(match I18n.t("validations.lettings.household.ppostcode_full.same_la_just_moved_to_area")) expect(record.errors["la"]) - .to include(match I18n.t("validations.lettings.household.la.same_la_just_moved_to_area.current_la")) + .to include(match I18n.t("validations.lettings.household.la.same_la_just_moved_to_area")) expect(record.errors["postcode_full"]) - .to include(match I18n.t("validations.lettings.household.postcode_full.same_la_just_moved_to_area.current_la")) + .to include(match I18n.t("validations.lettings.household.postcode_full.same_la_just_moved_to_area")) expect(record.errors["uprn"]) - .to include(match I18n.t("validations.lettings.household.uprn.same_la_just_moved_to_area.current_la")) + .to include(match I18n.t("validations.lettings.household.uprn.same_la_just_moved_to_area")) end end end