From c3ddae8e921a75543ee6e47f53946c72e6ba0b20 Mon Sep 17 00:00:00 2001 From: Kat <54268893+kosiakkatrina@users.noreply.github.com> Date: Wed, 13 Nov 2024 16:06:35 +0000 Subject: [PATCH] Update error messages --- .../validations/property_validations.rb | 8 ++++++-- .../validations/sales/property_validations.rb | 6 +++++- .../lettings/property_information.en.yml | 20 ++++++++++--------- .../sales/property_information.en.yml | 13 ++++++------ .../validations/property_validations_spec.rb | 4 ++-- .../sales/property_validations_spec.rb | 2 +- 6 files changed, 32 insertions(+), 21 deletions(-) diff --git a/app/models/validations/property_validations.rb b/app/models/validations/property_validations.rb index 9011b0b44..e9eba8184 100644 --- a/app/models/validations/property_validations.rb +++ b/app/models/validations/property_validations.rb @@ -59,14 +59,18 @@ module Validations::PropertyValidations record.errors.add :uprn, I18n.t("validations.lettings.property.uprn.not_in_england") record.errors.add :uprn_confirmation, I18n.t("validations.lettings.property.uprn_confirmation.not_in_england") record.errors.add :uprn_selection, I18n.t("validations.lettings.property.uprn_selection.not_in_england") - record.errors.add :startdate, I18n.t("validations.lettings.property.startdate.not_in_england") + if record.uprn.present? + record.errors.add :startdate, I18n.t("validations.lettings.property.startdate.address_not_in_england") + else + record.errors.add :startdate, I18n.t("validations.lettings.property.startdate.postcode_not_in_england") + end elsif record.is_supported_housing? return unless record.location return if record.location.location_code.in?(LocalAuthority.england.pluck(:code)) record.errors.add :location_id, I18n.t("validations.lettings.property.location_id.not_in_england") record.errors.add :scheme_id, I18n.t("validations.lettings.property.scheme_id.not_in_england") - record.errors.add :startdate, I18n.t("validations.lettings.property.startdate.not_in_england") + record.errors.add :startdate, I18n.t("validations.lettings.property.startdate.location_not_in_england") end end end diff --git a/app/models/validations/sales/property_validations.rb b/app/models/validations/sales/property_validations.rb index 569704862..b3a60eee6 100644 --- a/app/models/validations/sales/property_validations.rb +++ b/app/models/validations/sales/property_validations.rb @@ -46,6 +46,10 @@ module Validations::Sales::PropertyValidations record.errors.add :uprn, I18n.t("validations.sales.property_information.uprn.not_in_england") record.errors.add :uprn_confirmation, I18n.t("validations.sales.property_information.uprn_confirmation.not_in_england") record.errors.add :uprn_selection, I18n.t("validations.sales.property_information.uprn_selection.not_in_england") - record.errors.add :saledate, I18n.t("validations.sales.property_information.saledate.not_in_england") + if record.uprn.present? + record.errors.add :saledate, I18n.t("validations.sales.property_information.saledate.address_not_in_england") + else + record.errors.add :saledate, I18n.t("validations.sales.property_information.saledate.postcode_not_in_england") + end end end diff --git a/config/locales/validations/lettings/property_information.en.yml b/config/locales/validations/lettings/property_information.en.yml index 35866e42b..94207a8cf 100644 --- a/config/locales/validations/lettings/property_information.en.yml +++ b/config/locales/validations/lettings/property_information.en.yml @@ -4,7 +4,7 @@ en: property: postcode_full: invalid: "Enter a postcode in the correct format, for example AA1 1AA." - not_in_england: "It looks like you have entered a postcode for a local authority outside of England - only submit Lettings forms for Lettings that occur in England" + not_in_england: "It looks like you have entered a postcode outside of England - only submit Lettings forms for Lettings that occur in England" rsnvac: non_temp_accommodation: "Answer cannot be re-let to tenant who occupied the same property as temporary accommodation as this accommodation is not temporary." referral_invalid: "Answer cannot be re-let to tenant who occupied the same property as temporary accommodation as a different source of referral for this letting." @@ -19,16 +19,18 @@ en: one_seven_bedroom_shared: "A shared house must have 1 to 7 bedrooms." uprn: invalid: "UPRN must be 12 digits or less." - not_in_england: "It looks like you have entered a UPRN for a local authority outside of England - only submit Lettings forms for Lettings that occur in England" + not_in_england: "It looks like you have entered an address outside of England - only submit Lettings forms for Lettings that occur in England" uprn_confirmation: - not_in_england: "It looks like you have entered a UPRN for a local authority outside of England - only submit Lettings forms for Lettings that occur in England" + not_in_england: "It looks like you have entered an address outside of England - only submit Lettings forms for Lettings that occur in England" uprn_selection: - not_in_england: "It looks like you have selected an address for a local authority outside of England - only submit Lettings forms for Lettings that occur in England" + not_in_england: "It looks like you have entered an address outside of England - only submit Lettings forms for Lettings that occur in England" la: - not_in_england: "It looks like you have entered a local authority outside of England - only submit Lettings forms for Lettings that occur in England" + not_in_england: "It looks like you have entered an address outside of England - only submit Lettings forms for Lettings that occur in England" scheme_id: - not_in_england: "It looks like you have selected a location with a local authority outside of England - only submit Lettings forms for Lettings that occur in England" + not_in_england: "“It looks like you have selected a location outside of England - only submit Lettings forms for Lettings that occur in England" location_id: - not_in_england: "It looks like you have selected a location with a local authority outside of England - only submit Lettings forms for Lettings that occur in England" - startdate: - not_in_england: "It looks like you have selected a local authority outside of England - only submit Lettings forms for Lettings that occur in England" + not_in_england: "“It looks like you have selected a location outside of England - only submit Lettings forms for Lettings that occur in England" + startdate: + postcode_not_in_england: "It looks like you have entered an address outside of England - only submit Lettings forms for Lettings that occur in England" + address_not_in_england: "It looks like you have entered a postcode outside of England - only submit Lettings forms for Lettings that occur in England" + location_not_in_england: "“It looks like you have selected a location outside of England - only submit Lettings forms for Lettings that occur in England" diff --git a/config/locales/validations/sales/property_information.en.yml b/config/locales/validations/sales/property_information.en.yml index 2feb60982..ac6a69b4d 100644 --- a/config/locales/validations/sales/property_information.en.yml +++ b/config/locales/validations/sales/property_information.en.yml @@ -7,7 +7,7 @@ en: joint_purchase: "Buyers’ last accommodation and discounted ownership postcodes must match." not_joint_purchase: "Buyer’s last accommodation and discounted ownership postcodes must match." invalid: "Enter a postcode in the correct format, for example AA1 1AA." - not_in_england: "It looks like you have entered a postcode for a local authority outside of England - only submit Sales forms for Sales that occur in England" + not_in_england: "It looks like you have entered a postcode outside of England - only submit Lettings forms for Lettings that occur in England" ppostcode_full: postcode_must_match_previous: joint_purchase: "Buyers’ last accommodation and discounted ownership postcodes must match." @@ -21,7 +21,7 @@ en: joint_purchase: "Buyers’ last accommodation and discounted ownership postcodes must match." not_joint_purchase: "Buyer’s last accommodation and discounted ownership postcodes must match." invalid: "UPRN must be 12 digits or less." - not_in_england: "It looks like you have entered a UPRN for a local authority outside of England - only submit Sales forms for Sales that occur in England" + not_in_england: "It looks like you have entered an address outside of England - only submit Lettings forms for Lettings that occur in England" beds: bedsits_have_max_one_bedroom: "Number of bedrooms must be 1 if the property is a bedsit." proptype: @@ -29,10 +29,11 @@ en: uprn_known: invalid: "You must answer UPRN known?" la: - not_in_england: "It looks like you have entered a local authority outside of England - only submit Sales forms for Sales that occur in England" + not_in_england: "It looks like you have entered an address outside of England - only submit Lettings forms for Lettings that occur in England" uprn_confirmation: - not_in_england: "It looks like you have entered a UPRN for a local authority outside of England - only submit Sales forms for Sales that occur in England" + not_in_england: "It looks like you have entered an address outside of England - only submit Lettings forms for Lettings that occur in England" uprn_selection: - not_in_england: "It looks like you have selected an address for a local authority outside of England - only submit Sales forms for Sales that occur in England" + not_in_england: "It looks like you have entered an address outside of England - only submit Lettings forms for Lettings that occur in England" saledate: - not_in_england: "It looks like you have selected a local authority outside of England - only submit Sales forms for Sales that occur in England" + postcode_not_in_england: "It looks like you have entered an address outside of England - only submit Lettings forms for Lettings that occur in England" + address_not_in_england: "It looks like you have entered a postcode outside of England - only submit Lettings forms for Lettings that occur in England" diff --git a/spec/models/validations/property_validations_spec.rb b/spec/models/validations/property_validations_spec.rb index 82fa57223..142cb2491 100644 --- a/spec/models/validations/property_validations_spec.rb +++ b/spec/models/validations/property_validations_spec.rb @@ -221,7 +221,7 @@ RSpec.describe Validations::PropertyValidations do expect(log.errors["uprn"]).to include(I18n.t("validations.lettings.property.uprn.not_in_england")) expect(log.errors["uprn_confirmation"]).to include(I18n.t("validations.lettings.property.uprn_confirmation.not_in_england")) expect(log.errors["uprn_selection"]).to include(I18n.t("validations.lettings.property.uprn_selection.not_in_england")) - expect(log.errors["startdate"]).to include(I18n.t("validations.lettings.property.startdate.not_in_england")) + expect(log.errors["startdate"]).to include(I18n.t("validations.lettings.property.startdate.postcode_not_in_england")) expect(log.errors["scheme_id"]).to be_empty expect(log.errors["location_id"]).to be_empty end @@ -235,7 +235,7 @@ RSpec.describe Validations::PropertyValidations do property_validator.validate_la_in_england(log) expect(log.errors["scheme_id"]).to include(I18n.t("validations.lettings.property.scheme_id.not_in_england")) expect(log.errors["location_id"]).to include(I18n.t("validations.lettings.property.location_id.not_in_england")) - expect(log.errors["startdate"]).to include(I18n.t("validations.lettings.property.startdate.not_in_england")) + expect(log.errors["startdate"]).to include(I18n.t("validations.lettings.property.startdate.location_not_in_england")) expect(log.errors["la"]).to be_empty expect(log.errors["postcode_full"]).to be_empty expect(log.errors["uprn"]).to be_empty diff --git a/spec/models/validations/sales/property_validations_spec.rb b/spec/models/validations/sales/property_validations_spec.rb index 0fedd3fb0..c5af3ae78 100644 --- a/spec/models/validations/sales/property_validations_spec.rb +++ b/spec/models/validations/sales/property_validations_spec.rb @@ -159,7 +159,7 @@ RSpec.describe Validations::Sales::PropertyValidations do expect(log.errors["uprn"]).to include(I18n.t("validations.sales.property_information.uprn.not_in_england")) expect(log.errors["uprn_confirmation"]).to include(I18n.t("validations.sales.property_information.uprn_confirmation.not_in_england")) expect(log.errors["uprn_selection"]).to include(I18n.t("validations.sales.property_information.uprn_selection.not_in_england")) - expect(log.errors["saledate"]).to include(I18n.t("validations.sales.property_information.saledate.not_in_england")) + expect(log.errors["saledate"]).to include(I18n.t("validations.sales.property_information.saledate.postcode_not_in_england")) end end