From 2369fe8898ae418546886a3850d9eb3bce8fed3a Mon Sep 17 00:00:00 2001 From: Kat Date: Mon, 8 Aug 2022 09:15:50 +0100 Subject: [PATCH] Change property major repairs date validation from 2 years to 10 --- app/models/validations/date_validations.rb | 2 +- spec/models/validations/date_validations_spec.rb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/validations/date_validations.rb b/app/models/validations/date_validations.rb index 774f9828c..946cfa6c2 100644 --- a/app/models/validations/date_validations.rb +++ b/app/models/validations/date_validations.rb @@ -9,7 +9,7 @@ module Validations::DateValidations record.errors.add :mrcdate, I18n.t("validations.property.mrcdate.not_first_let") end - if record["mrcdate"].present? && record["startdate"].present? && record["startdate"].to_date - record["mrcdate"].to_date > 730 + if record["mrcdate"].present? && record["startdate"].present? && record["startdate"].to_date - record["mrcdate"].to_date > 3650 record.errors.add :mrcdate, I18n.t("validations.property.mrcdate.730_days_before_tenancy_start") end end diff --git a/spec/models/validations/date_validations_spec.rb b/spec/models/validations/date_validations_spec.rb index ca09c28c8..fcee95189 100644 --- a/spec/models/validations/date_validations_spec.rb +++ b/spec/models/validations/date_validations_spec.rb @@ -85,17 +85,17 @@ RSpec.describe Validations::DateValidations do expect(record.errors["mrcdate"]).to be_empty end - it "cannot be more than 2 years before the tenancy start date" do + it "cannot be more than 10 years before the tenancy start date" do record.startdate = Time.zone.local(2022, 2, 1) - record.mrcdate = Time.zone.local(2020, 1, 1) + record.mrcdate = Time.zone.local(2012, 1, 1) date_validator.validate_property_major_repairs(record) expect(record.errors["mrcdate"]) .to include(match I18n.t("validations.property.mrcdate.730_days_before_tenancy_start")) end - it "must be within 2 years of the tenancy start date" do + it "must be within 10 years of the tenancy start date" do record.startdate = Time.zone.local(2022, 2, 1) - record.mrcdate = Time.zone.local(2020, 3, 1) + record.mrcdate = Time.zone.local(2012, 3, 1) date_validator.validate_property_major_repairs(record) expect(record.errors["mrcdate"]).to be_empty end