diff --git a/app/models/validations/tenancy_validations.rb b/app/models/validations/tenancy_validations.rb index 86fd6f8d7..29afc4b77 100644 --- a/app/models/validations/tenancy_validations.rb +++ b/app/models/validations/tenancy_validations.rb @@ -12,7 +12,7 @@ module Validations::TenancyValidations min_tenancy_length = 1 return if record.tenancylength.to_i.between?(min_tenancy_length, 99) - message = record.is_assured_shorthold_tenancy? ? I18n.t("validations.tenancy.length.shorthold", min_tenancy_length:) : I18n.t("validations.tenancy.length.secure", min_tenancy_length:) + message = I18n.t("validations.tenancy.length.invalid_fixed", min_tenancy_length:) record.errors.add :needstype, message record.errors.add :rent_type, message record.errors.add :tenancylength, :tenancylength_invalid, message: message @@ -26,7 +26,7 @@ module Validations::TenancyValidations min_tenancy_length = 2 return if record.tenancylength.to_i.between?(min_tenancy_length, 99) - message = record.is_assured_shorthold_tenancy? ? I18n.t("validations.tenancy.length.shorthold", min_tenancy_length:) : I18n.t("validations.tenancy.length.secure", min_tenancy_length:) + message = I18n.t("validations.tenancy.length.invalid_fixed", min_tenancy_length:) record.errors.add :needstype, message record.errors.add :rent_type, message record.errors.add :tenancylength, :tenancylength_invalid, message: message @@ -40,7 +40,7 @@ module Validations::TenancyValidations min_tenancy_length = 1 return if record.tenancylength.to_i.between?(min_tenancy_length, 99) - message = record.is_assured_shorthold_tenancy? ? I18n.t("validations.tenancy.length.shorthold", min_tenancy_length:) : I18n.t("validations.tenancy.length.secure", min_tenancy_length:) + message = I18n.t("validations.tenancy.length.invalid_fixed", min_tenancy_length:) record.errors.add :needstype, message record.errors.add :rent_type, message record.errors.add :tenancylength, :tenancylength_invalid, message: message @@ -53,7 +53,7 @@ module Validations::TenancyValidations min_tenancy_length = 1 return if record.tenancylength.to_i.between?(min_tenancy_length, 99) - message = I18n.t("validations.tenancy.length.secure", min_tenancy_length:) + message = I18n.t("validations.tenancy.length.invalid_periodic", min_tenancy_length:) record.errors.add :tenancylength, :tenancylength_invalid, message: message record.errors.add :tenancy, message end diff --git a/config/locales/en.yml b/config/locales/en.yml index 9238347f8..e587a6fa7 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -557,8 +557,8 @@ en: tenancy: length: fixed_term_not_required: "You must only answer the length of the tenancy if it's fixed-term" - shorthold: "Enter a tenancy length between %{min_tenancy_length} and 99 years for a tenancy of this type" - secure: "Enter a tenancy length between %{min_tenancy_length} and 99 years (or don't specify the length) for a tenancy of this type" + invalid_fixed: "Enter a tenancy length between %{min_tenancy_length} and 99 years for a tenancy of this type" + invalid_periodic: "Enter a tenancy length between %{min_tenancy_length} and 99 years (or don't specify the length) for a tenancy of this type" internal_transfer: "Answer must be secure tenancy as this tenancy is an internal transfer" cannot_be_internal_transfer: "Answer cannot be internal transfer as this is not a secure tenancy" not_joint: "This cannot be a joint tenancy as you've told us there's only one person in the household" @@ -690,7 +690,7 @@ Make sure these answers are correct." shared_ownership_deposit: title_text: "You told us that the %{mortgage_deposit_and_discount_error_fields} add up to %{mortgage_deposit_and_discount_total}" old_persons_shared_ownership: - title_text: + title_text: one: "You told us the buyer is using the Older Persons Shared Ownership scheme." two: "You told us the buyers are using the Older Persons Shared Ownership scheme." hint_text: "At least one buyer must be aged 65 years and over to use this scheme." @@ -717,12 +717,12 @@ Make sure these answers are correct." title_text: "You told us that the percentage discount is %{discount}." hint_text: "This is higher than we would expect." savings: - title_text: + title_text: one: "You told us the buyer’s savings were %{savings}." two: "You told us the buyers’ savings were %{savings}." hint_text: "This is higher than we would expect." deposit: - title_text: + title_text: one: "You told us the buyer’s deposit was %{deposit} and their savings were %{savings}." two: "You told us the buyers’ deposit was %{deposit} and their savings were %{savings}." hint_text: "The deposit amount is higher than we would expect for the amount of savings they have." diff --git a/spec/models/validations/tenancy_validations_spec.rb b/spec/models/validations/tenancy_validations_spec.rb index 8b92329c7..282e94012 100644 --- a/spec/models/validations/tenancy_validations_spec.rb +++ b/spec/models/validations/tenancy_validations_spec.rb @@ -76,13 +76,13 @@ RSpec.describe Validations::TenancyValidations do { name: "assured shorthold", code: 4, - expected_error: ->(min_tenancy_length) { I18n.t("validations.tenancy.length.shorthold", min_tenancy_length:) }, + expected_error: ->(min_tenancy_length) { I18n.t("validations.tenancy.length.invalid_fixed", min_tenancy_length:) }, error_fields: %w[needstype rent_type tenancylength tenancy], }, { name: "secure fixed term", code: 6, - expected_error: ->(min_tenancy_length) { I18n.t("validations.tenancy.length.secure", min_tenancy_length:) }, + expected_error: ->(min_tenancy_length) { I18n.t("validations.tenancy.length.invalid_fixed", min_tenancy_length:) }, error_fields: %w[needstype rent_type tenancylength tenancy], }, ] @@ -210,7 +210,7 @@ RSpec.describe Validations::TenancyValidations do periodic_tenancy_case = { name: "periodic", code: 8, - expected_error: ->(min_tenancy_length) { I18n.t("validations.tenancy.length.secure", min_tenancy_length:) }, + expected_error: ->(min_tenancy_length) { I18n.t("validations.tenancy.length.invalid_periodic", min_tenancy_length:) }, error_fields: %w[tenancylength tenancy], } include_examples "adds expected errors based on the tenancy length", periodic_tenancy_case, 1