|
|
|
@ -68,23 +68,46 @@ RSpec.describe Validations::DateValidations do
|
|
|
|
|
expect(record.errors["mrcdate"]).to be_empty |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
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(2012, 1, 1) |
|
|
|
|
date_validator.validate_property_major_repairs(record) |
|
|
|
|
date_validator.validate_startdate(record) |
|
|
|
|
expect(record.errors["mrcdate"]) |
|
|
|
|
.to include(match I18n.t("validations.lettings.date.mrcdate.ten_years_before_tenancy_start")) |
|
|
|
|
expect(record.errors["startdate"]) |
|
|
|
|
.to include(match I18n.t("validations.lettings.date.startdate.ten_years_after_mrc_date")) |
|
|
|
|
context "with 2024 logs or earlier" do |
|
|
|
|
it "cannot be more than 10 years before the tenancy start date" do |
|
|
|
|
record.startdate = Time.zone.local(2024, 2, 1) |
|
|
|
|
record.mrcdate = Time.zone.local(2014, 1, 1) |
|
|
|
|
date_validator.validate_property_major_repairs(record) |
|
|
|
|
date_validator.validate_startdate(record) |
|
|
|
|
expect(record.errors["mrcdate"]) |
|
|
|
|
.to include(match I18n.t("validations.lettings.date.mrcdate.ten_years_before_tenancy_start")) |
|
|
|
|
expect(record.errors["startdate"]) |
|
|
|
|
.to include(match I18n.t("validations.lettings.date.startdate.ten_years_after_mrc_date")) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "must be within 10 years of the tenancy start date" do |
|
|
|
|
record.startdate = Time.zone.local(2024, 2, 1) |
|
|
|
|
record.mrcdate = Time.zone.local(2014, 3, 1) |
|
|
|
|
date_validator.validate_property_major_repairs(record) |
|
|
|
|
expect(record.errors["mrcdate"]).to be_empty |
|
|
|
|
expect(record.errors["startdate"]).to be_empty |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
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(2012, 3, 1) |
|
|
|
|
date_validator.validate_property_major_repairs(record) |
|
|
|
|
expect(record.errors["mrcdate"]).to be_empty |
|
|
|
|
expect(record.errors["startdate"]).to be_empty |
|
|
|
|
context "with 2025 logs or later" do |
|
|
|
|
it "cannot be more than 20 years before the tenancy start date" do |
|
|
|
|
record.startdate = Time.zone.local(2026, 2, 1) |
|
|
|
|
record.mrcdate = Time.zone.local(2006, 1, 1) |
|
|
|
|
date_validator.validate_property_major_repairs(record) |
|
|
|
|
date_validator.validate_startdate(record) |
|
|
|
|
expect(record.errors["mrcdate"]) |
|
|
|
|
.to include(match I18n.t("validations.lettings.date.mrcdate.twenty_years_before_tenancy_start")) |
|
|
|
|
expect(record.errors["startdate"]) |
|
|
|
|
.to include(match I18n.t("validations.lettings.date.startdate.twenty_years_after_mrc_date")) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "must be within 20 years of the tenancy start date" do |
|
|
|
|
record.startdate = Time.zone.local(2026, 2, 1) |
|
|
|
|
record.mrcdate = Time.zone.local(2006, 3, 1) |
|
|
|
|
date_validator.validate_property_major_repairs(record) |
|
|
|
|
expect(record.errors["mrcdate"]).to be_empty |
|
|
|
|
expect(record.errors["startdate"]).to be_empty |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when reason for vacancy is first let of property" do |
|
|
|
@ -139,23 +162,46 @@ RSpec.describe Validations::DateValidations do
|
|
|
|
|
expect(record.errors["voiddate"]).to be_empty |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "cannot be more than 10 years before the tenancy start date" do |
|
|
|
|
record.startdate = Time.zone.local(2022, 2, 1) |
|
|
|
|
record.voiddate = Time.zone.local(2012, 1, 1) |
|
|
|
|
date_validator.validate_property_void_date(record) |
|
|
|
|
date_validator.validate_startdate(record) |
|
|
|
|
expect(record.errors["voiddate"]) |
|
|
|
|
.to include(match I18n.t("validations.lettings.date.void_date.ten_years_before_tenancy_start")) |
|
|
|
|
expect(record.errors["startdate"]) |
|
|
|
|
.to include(match I18n.t("validations.lettings.date.startdate.ten_years_after_void_date")) |
|
|
|
|
context "with 2024 logs or earlier" do |
|
|
|
|
it "cannot be more than 10 years before the tenancy start date" do |
|
|
|
|
record.startdate = Time.zone.local(2024, 2, 1) |
|
|
|
|
record.voiddate = Time.zone.local(2014, 1, 1) |
|
|
|
|
date_validator.validate_property_void_date(record) |
|
|
|
|
date_validator.validate_startdate(record) |
|
|
|
|
expect(record.errors["voiddate"]) |
|
|
|
|
.to include(match I18n.t("validations.lettings.date.void_date.ten_years_before_tenancy_start")) |
|
|
|
|
expect(record.errors["startdate"]) |
|
|
|
|
.to include(match I18n.t("validations.lettings.date.startdate.ten_years_after_void_date")) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "must be within 10 years of the tenancy start date" do |
|
|
|
|
record.startdate = Time.zone.local(2024, 2, 1) |
|
|
|
|
record.voiddate = Time.zone.local(2014, 3, 1) |
|
|
|
|
date_validator.validate_property_void_date(record) |
|
|
|
|
expect(record.errors["voiddate"]).to be_empty |
|
|
|
|
expect(record.errors["startdate"]).to be_empty |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "must be within 10 years of the tenancy start date" do |
|
|
|
|
record.startdate = Time.zone.local(2022, 2, 1) |
|
|
|
|
record.voiddate = Time.zone.local(2012, 3, 1) |
|
|
|
|
date_validator.validate_property_void_date(record) |
|
|
|
|
expect(record.errors["voiddate"]).to be_empty |
|
|
|
|
expect(record.errors["startdate"]).to be_empty |
|
|
|
|
context "with 2025 logs or later" do |
|
|
|
|
it "cannot be more than 20 years before the tenancy start date" do |
|
|
|
|
record.startdate = Time.zone.local(2026, 2, 1) |
|
|
|
|
record.voiddate = Time.zone.local(2006, 1, 1) |
|
|
|
|
date_validator.validate_property_void_date(record) |
|
|
|
|
date_validator.validate_startdate(record) |
|
|
|
|
expect(record.errors["voiddate"]) |
|
|
|
|
.to include(match I18n.t("validations.lettings.date.void_date.twenty_years_before_tenancy_start")) |
|
|
|
|
expect(record.errors["startdate"]) |
|
|
|
|
.to include(match I18n.t("validations.lettings.date.startdate.twenty_years_after_void_date")) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "must be within 20 years of the tenancy start date" do |
|
|
|
|
record.startdate = Time.zone.local(2026, 2, 1) |
|
|
|
|
record.voiddate = Time.zone.local(2006, 3, 1) |
|
|
|
|
date_validator.validate_property_void_date(record) |
|
|
|
|
expect(record.errors["voiddate"]).to be_empty |
|
|
|
|
expect(record.errors["startdate"]).to be_empty |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when major repairs have been carried out" do |
|
|
|
|