From fc6dbc0ce9df3ca47b5ff0198a1a21c3fd093380 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Wed, 12 Oct 2022 17:12:30 +0100 Subject: [PATCH] test: add tests for new validations --- spec/models/validations/date_validations_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/models/validations/date_validations_spec.rb b/spec/models/validations/date_validations_spec.rb index 35ff79b99..0b20ab07a 100644 --- a/spec/models/validations/date_validations_spec.rb +++ b/spec/models/validations/date_validations_spec.rb @@ -41,6 +41,22 @@ RSpec.describe Validations::DateValidations do .to include(match I18n.t("validations.setup.startdate.before_scheme_end_date")) end + it "validates that the tenancy start date is after the void date if it has a void date" do + record.startdate = Time.zone.local(2022, 1, 1) + record.voiddate = Time.zone.local(2022, 2, 1) + date_validator.validate_startdate(record) + expect(record.errors["startdate"]) + .to include(match I18n.t("validations.setup.startdate.after_void_date")) + end + + it "validates that the tenancy start date is after the major repair date if it has a major repair date" do + record.startdate = Time.zone.local(2022, 1, 1) + record.mrcdate = Time.zone.local(2022, 2, 1) + date_validator.validate_startdate(record) + expect(record.errors["startdate"]) + .to include(match I18n.t("validations.setup.startdate.after_major_repair_date")) + end + it "produces no error when the tenancy start date is before the end date of the chosen scheme if it has an end date" do record.startdate = Time.zone.today - 30.days record.scheme = scheme