From c3595b5eda137c5300351c7f1aa9033dc7b782f3 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Wed, 15 Mar 2023 12:35:39 +0000 Subject: [PATCH] feat: fix tenancy_validations_spec.rb --- .../validations/tenancy_validations_spec.rb | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spec/models/validations/tenancy_validations_spec.rb b/spec/models/validations/tenancy_validations_spec.rb index 2d008e6e3..8f7d79e29 100644 --- a/spec/models/validations/tenancy_validations_spec.rb +++ b/spec/models/validations/tenancy_validations_spec.rb @@ -3,6 +3,10 @@ require "rails_helper" RSpec.describe Validations::TenancyValidations do subject(:tenancy_validator) { validator_class.new } + before do + Timecop.freeze(Time.zone.local(2021, 5, 1)) + end + let(:validator_class) { Class.new { include Validations::TenancyValidations } } let(:record) { FactoryBot.create(:lettings_log, startdate: Time.zone.local(2021, 5, 1), needstype: 1, rent_type: 1) } @@ -117,6 +121,14 @@ RSpec.describe Validations::TenancyValidations do end context "when the collection start year is 2022 or later" do + before do + Timecop.freeze(2022, 5, 1) + end + + after do + Timecop.unfreeze + end + let(:record) { FactoryBot.create(:lettings_log, startdate: Time.zone.local(2022, 5, 1), needstype: 1, rent_type: 1) } context "when type of tenancy is Secure - fixed term" do @@ -260,6 +272,14 @@ RSpec.describe Validations::TenancyValidations do describe "joint tenancy validation" do context "when the data inputter has said that there is only one member in the household" do + before do + Timecop.freeze(2022, 5, 1) + end + + after do + Timecop.unfreeze + end + let(:record) { FactoryBot.create(:lettings_log, startdate: Time.zone.local(2022, 5, 1)) } let(:expected_error) { I18n.t("validations.tenancy.not_joint") } let(:hhmemb_expected_error) { I18n.t("validations.tenancy.joint_more_than_one_member") }