Browse Source

CLDC-3820: Ensure la/prevloc/layear validation is triggered on fields which cause la to be inferred (#2884)

CLDC-3787-Autocomplete-address-search^2
Rachael Booth 5 days ago committed by GitHub
parent
commit
e3a3c2ebb0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 15
      app/models/validations/household_validations.rb
  2. 9
      config/locales/validations/lettings/household.en.yml
  3. 18
      spec/models/validations/household_validations_spec.rb

15
app/models/validations/household_validations.rb

@ -202,12 +202,15 @@ module Validations::HouseholdValidations
return unless record.layear && record.la && record.prevloc && record.collection_start_year
if record.la == record.prevloc && record.layear == 1
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")
record.errors.add :layear, I18n.t("validations.lettings.household.layear.same_la_just_moved_to_area")
record.errors.add :la, I18n.t("validations.lettings.household.la.same_la_just_moved_to_area")
record.errors.add :postcode_full, I18n.t("validations.lettings.household.postcode_full.same_la_just_moved_to_area")
record.errors.add :uprn, I18n.t("validations.lettings.household.uprn.same_la_just_moved_to_area")
record.errors.add :uprn_selection, I18n.t("validations.lettings.household.uprn_selection.same_la_just_moved_to_area")
record.errors.add :ppostcode_full, I18n.t("validations.lettings.household.ppostcode_full.same_la_just_moved_to_area")
record.errors.add :prevloc, I18n.t("validations.lettings.household.prevloc.same_la_just_moved_to_area")
record.errors.add :scheme_id, :skip_bu_error, message: I18n.t("validations.lettings.household.scheme.same_la_just_moved_to_area")
record.errors.add :location_id, :skip_bu_error, message: I18n.t("validations.lettings.household.location.same_la_just_moved_to_area")
end
end

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

@ -57,6 +57,15 @@ en:
uprn:
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"
uprn_selection:
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"
scheme:
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"
location:
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’."
child_under_16_ecstat: "Answer cannot be under 16 as person %{person_num}’s working situation is not ‘child under 16’, ‘other’ or ‘prefers not to say’."

18
spec/models/validations/household_validations_spec.rb

@ -668,17 +668,23 @@ 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"))
.to include(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"))
.to include(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"))
.to include(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"))
.to include(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"))
.to include(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"))
.to include(I18n.t("validations.lettings.household.uprn.same_la_just_moved_to_area"))
expect(record.errors["uprn_selection"])
.to include(I18n.t("validations.lettings.household.uprn_selection.same_la_just_moved_to_area"))
expect(record.errors["scheme_id"])
.to include(I18n.t("validations.lettings.household.scheme.same_la_just_moved_to_area"))
expect(record.errors["location_id"])
.to include(I18n.t("validations.lettings.household.location.same_la_just_moved_to_area"))
end
end
end

Loading…
Cancel
Save