Browse Source

Increase year range for 2025 void and major repairs dates soft validations (#2979)

pull/2998/head
kosiakkatrina 4 days ago committed by GitHub
parent
commit
dc4b733245
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 7
      app/models/validations/soft_validations.rb
  2. 36
      spec/models/validations/soft_validations_spec.rb

7
app/models/validations/soft_validations.rb

@ -103,13 +103,16 @@ module Validations::SoftValidations
TWO_YEARS_IN_DAYS = 730
TEN_YEARS_IN_DAYS = 3650
TWENTY_YEARS_IN_DAYS = 7300
def major_repairs_date_in_soft_range?
mrcdate.present? && startdate.present? && mrcdate.between?(startdate.to_date - TEN_YEARS_IN_DAYS, startdate.to_date - TWO_YEARS_IN_DAYS)
upper_limit = form.start_year_2025_or_later? ? TWENTY_YEARS_IN_DAYS : TEN_YEARS_IN_DAYS
mrcdate.present? && startdate.present? && mrcdate.between?(startdate.to_date - upper_limit, startdate.to_date - TWO_YEARS_IN_DAYS)
end
def voiddate_in_soft_range?
voiddate.present? && startdate.present? && voiddate.between?(startdate.to_date - TEN_YEARS_IN_DAYS, startdate.to_date - TWO_YEARS_IN_DAYS)
upper_limit = form.start_year_2025_or_later? ? TWENTY_YEARS_IN_DAYS : TEN_YEARS_IN_DAYS
voiddate.present? && startdate.present? && voiddate.between?(startdate.to_date - upper_limit, startdate.to_date - TWO_YEARS_IN_DAYS)
end
def net_income_higher_or_lower_text

36
spec/models/validations/soft_validations_spec.rb

@ -265,6 +265,24 @@ RSpec.describe Validations::SoftValidations do
expect(record.major_repairs_date_in_soft_range?).to be false
end
end
context "with 2025 logs" do
context "when the void date is within 20 years of the tenancy start date" do
it "shows the interruption screen" do
record.startdate = Time.zone.local(2026, 2, 1)
record.mrcdate = Time.zone.local(2007, 2, 1)
expect(record.major_repairs_date_in_soft_range?).to be true
end
end
context "when the void date is less than 2 years before the tenancy start date" do
it "does not show the interruption screen" do
record.startdate = Time.zone.local(2026, 2, 1)
record.mrcdate = Time.zone.local(2025, 2, 1)
expect(record.major_repairs_date_in_soft_range?).to be false
end
end
end
end
describe "void date soft validations" do
@ -283,6 +301,24 @@ RSpec.describe Validations::SoftValidations do
expect(record.voiddate_in_soft_range?).to be false
end
end
context "with 2025 logs" do
context "when the void date is within 20 years of the tenancy start date" do
it "shows the interruption screen" do
record.startdate = Time.zone.local(2026, 2, 1)
record.voiddate = Time.zone.local(2007, 2, 1)
expect(record.voiddate_in_soft_range?).to be true
end
end
context "when the void date is less than 2 years before the tenancy start date" do
it "does not show the interruption screen" do
record.startdate = Time.zone.local(2026, 2, 1)
record.voiddate = Time.zone.local(2025, 2, 1)
expect(record.voiddate_in_soft_range?).to be false
end
end
end
end
describe "old persons shared ownership soft validations" do

Loading…
Cancel
Save