From 68fdf49f843143359760941a042946efb47e9928 Mon Sep 17 00:00:00 2001 From: David May-Miller Date: Tue, 8 Nov 2022 16:12:44 +0000 Subject: [PATCH] CLDC-1698 Simplify tenancy length range error message --- app/models/validations/tenancy_validations.rb | 24 +------------------ config/locales/en.yml | 4 ++-- .../validations/tenancy_validations_spec.rb | 8 ------- 3 files changed, 3 insertions(+), 33 deletions(-) diff --git a/app/models/validations/tenancy_validations.rb b/app/models/validations/tenancy_validations.rb index c2dc96b01..4a356aab0 100644 --- a/app/models/validations/tenancy_validations.rb +++ b/app/models/validations/tenancy_validations.rb @@ -16,8 +16,6 @@ module Validations::TenancyValidations error: I18n.t( "validations.tenancy.length.shorthold", min_tenancy_length: min_tenancy_length(record), - rent_type: rent_type_mapping(record)[record.rent_type], - needs_type: needs_type_mapping[record.needstype], ), }, { @@ -25,8 +23,6 @@ module Validations::TenancyValidations error: I18n.t( "validations.tenancy.length.secure", min_tenancy_length: min_tenancy_length(record), - rent_type: rent_type_mapping(record)[record.rent_type], - needs_type: needs_type_mapping[record.needstype], ), }, ] @@ -53,24 +49,6 @@ module Validations::TenancyValidations end def min_tenancy_length(record) - record.needstype == 2 || record.rent_type.in?([3, 5]) ? 1 : 2 - end - - def rent_type_mapping(record) - { - 1 => "Affordable Rent", - 2 => "London Affordable Rent", - 4 => "London Living Rent", - 3 => "Rent to Buy", - 0 => "Social Rent", - 5 => record.irproduct, - } - end - - def needs_type_mapping - { - 1 => "General needs", - 2 => "Supported housing", - } + record.needstype == 2 || record.renttype == 3 ? 1 : 2 end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 80a9247cf..55ea3a0f7 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -301,8 +301,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 %{needs_type} %{rent_type} Fixed Term – Assured Shorthold Tenancy (AST)" - secure: "Enter a tenancy length between %{min_tenancy_length} and 99 years (or don't specify the length) for a %{needs_type} %{rent_type} Secure (including flexible) tenancy" + 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" 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" diff --git a/spec/models/validations/tenancy_validations_spec.rb b/spec/models/validations/tenancy_validations_spec.rb index c88cc86a0..2d008e6e3 100644 --- a/spec/models/validations/tenancy_validations_spec.rb +++ b/spec/models/validations/tenancy_validations_spec.rb @@ -25,8 +25,6 @@ RSpec.describe Validations::TenancyValidations do I18n.t( "validations.tenancy.length.shorthold", min_tenancy_length: 2, - needs_type: "General needs", - rent_type: "Affordable Rent", ) end @@ -75,8 +73,6 @@ RSpec.describe Validations::TenancyValidations do I18n.t( "validations.tenancy.length.secure", min_tenancy_length: 2, - needs_type: "General needs", - rent_type: "Affordable Rent", ) end @@ -128,8 +124,6 @@ RSpec.describe Validations::TenancyValidations do I18n.t( "validations.tenancy.length.secure", min_tenancy_length: 2, - needs_type: "General needs", - rent_type: "Affordable Rent", ) end @@ -177,8 +171,6 @@ RSpec.describe Validations::TenancyValidations do I18n.t( "validations.tenancy.length.secure", min_tenancy_length: 2, - needs_type: "General needs", - rent_type: "Affordable Rent", ) end