From 84b0aa6e0a0d6542afa298491ed5fec612f2e395 Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Fri, 10 Feb 2023 11:13:06 +0000 Subject: [PATCH] move validation string to locales --- app/services/bulk_upload/lettings/row_parser.rb | 4 +--- config/locales/en.yml | 1 + spec/services/bulk_upload/lettings/row_parser_spec.rb | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/services/bulk_upload/lettings/row_parser.rb b/app/services/bulk_upload/lettings/row_parser.rb index 449074638..cee5fa319 100644 --- a/app/services/bulk_upload/lettings/row_parser.rb +++ b/app/services/bulk_upload/lettings/row_parser.rb @@ -185,9 +185,7 @@ private def leaving_reason_for_renewal if field_134 == 1 && ![40, 42].include?(field_52) - message = 'The reason for leaving must be "End of assured shorthold tenancy - no fault" or "End of fixed term tenancy - no fault" if the letting is a renewal' - - errors.add(:field_52, message) + errors.add(:field_52, I18n.t("validations.household.reason.renewal_reason_needed")) end end diff --git a/config/locales/en.yml b/config/locales/en.yml index f2e980cee..a97863c30 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -376,6 +376,7 @@ en: male_refuge: "Answer cannot be ‘male’ as you told us their housing situation immediately before this letting was a refuge" reason: not_internal_transfer: "Answer cannot be ‘permanently decanted from another property owned by this landlord’ as you told us the source of referral for this tenancy was not an internal transfer" + renewal_reason_needed: 'The reason for leaving must be "End of assured shorthold tenancy - no fault" or "End of fixed term tenancy - no fault" if the letting is a renewal' condition_effects: no_choices: "You cannot answer this question as you told us nobody in the household has a physical or mental health condition (or other illness) expected to last 12 months or more" postcode: diff --git a/spec/services/bulk_upload/lettings/row_parser_spec.rb b/spec/services/bulk_upload/lettings/row_parser_spec.rb index 898df685d..297b9fd46 100644 --- a/spec/services/bulk_upload/lettings/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/row_parser_spec.rb @@ -272,7 +272,6 @@ RSpec.describe BulkUpload::Lettings::RowParser do let(:attributes) { { bulk_upload:, field_52: "1", field_134: "1" } } it "is not permitted" do - parser.field_52 = "1" expect(parser.errors[:field_52]).to be_present end end