diff --git a/app/models/validations/sales/sale_information_validations.rb b/app/models/validations/sales/sale_information_validations.rb index bdbecd3cf..6997b1bcc 100644 --- a/app/models/validations/sales/sale_information_validations.rb +++ b/app/models/validations/sales/sale_information_validations.rb @@ -20,11 +20,11 @@ module Validations::Sales::SaleInformationValidations case record.type when 18 - record.errors.add :type, "Social HomeBuy buyers should not have lived here before" - record.errors.add :proplen, "Social HomeBuy or Rent to Buy buyers should not have lived here before" + record.errors.add :type, I18n.t("validations.sale_information.proplen.social_homebuy") + record.errors.add :proplen, I18n.t("validations.sale_information.proplen.social_homebuy") when 28, 29 - record.errors.add :type, "Rent to Buy buyers should not have lived here before" - record.errors.add :proplen, "Rent to Buy buyers should not have lived here before" + record.errors.add :type, I18n.t("validations.sale_information.proplen.rent_to_buy") + record.errors.add :proplen, I18n.t("validations.sale_information.proplen.rent_to_buy") end end end diff --git a/config/locales/en.yml b/config/locales/en.yml index fbfd0c8e0..beb54d679 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -300,7 +300,7 @@ en: child_over_20: "Answer cannot be 20 or over as the relationship is ‘child’" not_student_16_19: "Answer cannot be between 16 and 19 as person %{person_num} is a child of the lead tenant but is not a full-time student" student_16_19: - cannot_be_16_19: + cannot_be_16_19: student_not_child: "Person cannot be aged 16-19 if they are a student but don't have relationship ‘child’" child_not_student: "Person cannot be aged 16-19 if they have relationship ‘child’ but are not a student" must_be_16_19: "Person must be aged 16-19 if they are a student and have relationship ‘child’" @@ -312,8 +312,8 @@ en: child_under_16: "Person’s %{person_num} working situation must be ’child under 16‘ as you told us they’re under 16" child_over_16: "Answer cannot be ‘child under 16’ as you told us the person %{person_num} is older than 16" not_student_16_19: "Person’s %{person_num} working situation must be full-time student or prefers not to say as you told us they’re between 16 and 19." - student_16_19: - cannot_be_student: + student_16_19: + cannot_be_student: child_not_16_19: "Person cannot be a student if they are not aged 16-19 but have relationship ‘child’" 16_19_not_child: "Person cannot be a student if they are aged 16-19 but don‘t have relationship ‘child’" must_be_student: "Person must be a student if they are aged 16-19 and have relationship ‘child’" @@ -325,8 +325,8 @@ en: child_over_20: "Answer cannot be ‘child’ if the person's age is 20 or over" one_partner: "Number of partners cannot be greater than 1" not_student_16_19: "Answer cannot be ‘child’ as you told us the person %{person_num} is between 16 and 19 and is not a full-time student" - student_16_19: - cannot_be_child: + student_16_19: + cannot_be_child: student_not_16_19: "Answer cannot be ‘child’ if the person is a student but not aged 16-19" 16_19_not_student: "Answer cannot be ‘child’ if the person is aged 16-19 but not a student" must_be_child: "Answer must be ‘child’ if the person is aged 16-19 and a student" @@ -367,6 +367,10 @@ en: 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" 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" + sale_information: + proplen: + social_homebuy: "Social HomeBuy buyers should not have lived here before" + rent_to_buy: "Rent to Buy buyers should not have lived here before" tenancy: length: diff --git a/spec/models/validations/sales/sale_information_validations_spec.rb b/spec/models/validations/sales/sale_information_validations_spec.rb index b51a1348c..27df6a188 100644 --- a/spec/models/validations/sales/sale_information_validations_spec.rb +++ b/spec/models/validations/sales/sale_information_validations_spec.rb @@ -146,7 +146,8 @@ RSpec.describe Validations::Sales::SaleInformationValidations do it "adds an error" do sale_information_validator.validate_years_living_in_property_before_purchase(record) - expect(record.errors).to be_present + expect(record.errors[:type]).to include(I18n.t("validations.sale_information.proplen.rent_to_buy")) + expect(record.errors[:proplen]).to include(I18n.t("validations.sale_information.proplen.rent_to_buy")) end end @@ -156,7 +157,8 @@ RSpec.describe Validations::Sales::SaleInformationValidations do it "adds an error" do sale_information_validator.validate_years_living_in_property_before_purchase(record) - expect(record.errors).to be_present + expect(record.errors[:type]).to include(I18n.t("validations.sale_information.proplen.social_homebuy")) + expect(record.errors[:proplen]).to include(I18n.t("validations.sale_information.proplen.social_homebuy")) end end end