From 51361552238f5ab1bffc080c62387cf8e030965b Mon Sep 17 00:00:00 2001 From: oscar-richardson-softwire Date: Wed, 28 Jan 2026 10:31:27 +0000 Subject: [PATCH] Added `!record.read_attribute(:la)` guard --- app/models/validations/property_validations.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/validations/property_validations.rb b/app/models/validations/property_validations.rb index 121dc2cd0..8ed0afcde 100644 --- a/app/models/validations/property_validations.rb +++ b/app/models/validations/property_validations.rb @@ -84,7 +84,7 @@ module Validations::PropertyValidations else record.errors.add :startdate, I18n.t("validations.lettings.property.startdate.postcode_not_in_england") end - elsif record.is_supported_housing? # TODO: revisit + elsif record.is_supported_housing? && !record.read_attribute(:la) # `!record.read_attribute(:la)` being satisfied means the address questions (including LA) haven't been answered and the LA is coming from location. 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.location_not_in_england") @@ -109,7 +109,7 @@ module Validations::PropertyValidations record.errors.add :uprn, I18n.t("validations.lettings.property.uprn.la_not_valid_for_date", la: la.name) record.errors.add :uprn_selection, I18n.t("validations.lettings.property.uprn_selection.la_not_valid_for_date", la: la.name) record.errors.add :startdate, I18n.t("validations.lettings.property.startdate.la_not_valid_for_date", la: la.name) - elsif record.is_supported_housing? # TODO: revisit + elsif record.is_supported_housing? && !record.read_attribute(:la) # `!record.read_attribute(:la)` being satisfied means the address questions (including LA) haven't been answered and the LA is coming from location. record.errors.add :location_id, I18n.t("validations.lettings.property.location_id.la_not_valid_for_date", la: la.name) record.errors.add :scheme_id, I18n.t("validations.lettings.property.scheme_id.la_not_valid_for_date", la: la.name) record.errors.add :startdate, I18n.t("validations.lettings.property.startdate.la_not_valid_for_date", la: la.name)