From b9a5ac80c366f7d5bd9e10036b1440dcd6641115 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Mon, 14 Mar 2022 21:21:27 +0000 Subject: [PATCH] Update london postcode validation error message --- app/models/validations/property_validations.rb | 2 +- config/locales/en.yml | 1 + spec/models/validations/property_validations_spec.rb | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/validations/property_validations.rb b/app/models/validations/property_validations.rb index d02b8188a..8a72bdabb 100644 --- a/app/models/validations/property_validations.rb +++ b/app/models/validations/property_validations.rb @@ -58,7 +58,7 @@ module Validations::PropertyValidations if record.la.present? && !LONDON_BOROUGHS.include?(record.la) && record.is_london_rent? record.errors.add :la, I18n.t("validations.property.la.london_rent") if record.postcode_known? && record.property_postcode.present? - record.errors.add :property_postcode, I18n.t("validations.property.la.london_rent") + record.errors.add :property_postcode, I18n.t("validations.property.la.london_rent_postcode") end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 7eb9a57e4..154845233 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -61,6 +61,7 @@ en: relet_number: "Property number of times relet must be between 0 and 20" la: london_rent: "Local authority has to be in London" + london_rent_postcode: "The postcode must be a London postcode because you told us the rent type is London Affordable Rent or London Living Rent" la_known: "Enter a local authority" rsnvac: first_let_not_social: "Reason for vacancy cannot be first let if unit has been previously let as social housing" diff --git a/spec/models/validations/property_validations_spec.rb b/spec/models/validations/property_validations_spec.rb index 1539820a2..4461cd24f 100644 --- a/spec/models/validations/property_validations_spec.rb +++ b/spec/models/validations/property_validations_spec.rb @@ -167,6 +167,8 @@ RSpec.describe Validations::PropertyValidations do end context "when the la has been derived from a known postcode" do + let(:expected_error) { I18n.t("validations.property.la.london_rent_postcode") } + it "also adds an error to the postcode field" do record.la = "E07000105" record.rent_type = 2