Browse Source

Refactor, remove one level of keys

pull/2741/head
Manny Dinssa 8 months ago
parent
commit
40a077c36e
  1. 12
      app/models/validations/household_validations.rb
  2. 23
      config/locales/validations/lettings/household.en.yml
  3. 12
      spec/models/validations/household_validations_spec.rb

12
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 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 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 :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.current_la") 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.current_la") 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.current_la") 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.previous_la") 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.previous_la") record.errors.add :prevloc, :renewal_just_moved, message: I18n.t("validations.lettings.household.prevloc.same_la_just_moved_to_area")
end end
end end

23
config/locales/validations/lettings/household.en.yml

@ -36,33 +36,26 @@ en:
prevloc: prevloc:
previous_la_known: "Enter name of local authority." previous_la_known: "Enter name of local authority."
same_la_just_moved_to_area: 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."
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.'
renewal: 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: layear:
renewal_just_moved_to_area: 'The household cannot have just moved to the local authority area if this letting is a renewal' 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: same_la_just_moved_to_area: "You told us this tenant previously lived in this local authority. Check your answers are correct."
current_la: 'You told us this tenant previously lived in this local authority. Check your answers are correct.'
la: la:
same_la_just_moved_to_area: 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"
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'
postcode_full: postcode_full:
same_la_just_moved_to_area: 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"
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.'
ppostcode_full: ppostcode_full:
same_la_just_moved_to_area: 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."
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.'
uprn: uprn:
same_la_just_moved_to_area: 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"
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'
age: age:
child_under_16_relat: "Answer cannot be under 16 as person %{person_num}'s relationship to the lead tenant is ‘partner’." child_under_16_relat: "Answer cannot be under 16 as person %{person_num}'s relationship to the lead tenant is ‘partner’."

12
spec/models/validations/household_validations_spec.rb

@ -668,17 +668,17 @@ RSpec.describe Validations::HouseholdValidations do
record.startdate = Time.zone.now record.startdate = Time.zone.now
household_validator.validate_layear_and_prevloc(record) household_validator.validate_layear_and_prevloc(record)
expect(record.errors["layear"]) 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"]) 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"]) 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"]) 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"]) 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"]) 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 end
end end

Loading…
Cancel
Save