it"produces error when tenancy start date is during deactivated location period"do
record.startdate=Time.zone.local(2022,7,5)
record.location=location
setup_validator.validate_scheme(record)
expect(record.errors["scheme_id"])
.toinclude(matchI18n.t("validations.setup.startdate.location.reactivating_soon",postcode:location.postcode,date:"4 August 2022",deactivation_date:"4 June 2022"))
end
it"produces no error when tenancy start date is during an active location period"do
record.startdate=Time.zone.local(2022,9,1)
record.location=location
setup_validator.validate_scheme(record)
expect(record.errors["scheme_id"]).tobe_empty
end
end
context"with a location with no deactivation periods"do
it"produces error when tenancy start date is during deactivated scheme period"do
record.startdate=Time.zone.local(2022,7,5)
record.scheme=scheme
setup_validator.validate_scheme(record)
expect(record.errors["scheme_id"])
.toinclude(matchI18n.t("validations.setup.startdate.scheme.reactivating_soon",name:scheme.service_name,date:"4 August 2022",deactivation_date:"4 June 2022"))
end
it"produces no error when tenancy start date is during an active scheme period"do
record.startdate=Time.zone.local(2022,9,1)
record.scheme=scheme
setup_validator.validate_scheme(record)
expect(record.errors["scheme_id"]).tobe_empty
end
end
context"with a scheme that has many reactivations soon"do
it"produces error when tenancy start date is during deactivated scheme period"do
record.startdate=Time.zone.local(2022,7,5)
record.scheme=scheme
setup_validator.validate_scheme(record)
expect(record.errors["scheme_id"])
.toinclude(matchI18n.t("validations.setup.startdate.scheme.reactivating_soon",name:scheme.service_name,date:"4 September 2022",deactivation_date:"1 June 2022"))
end
it"produces no error when tenancy start date is during an active scheme period"do
it"produces error when tenancy start date is during deactivated location period"do
record.startdate=Time.zone.local(2022,7,5)
record.location=location
setup_validator.validate_location(record)
expect(record.errors["location_id"])
.toinclude(matchI18n.t("validations.setup.startdate.location.reactivating_soon",postcode:location.postcode,date:"4 August 2022",deactivation_date:"4 June 2022"))
end
it"produces no error when tenancy start date is during an active location period"do
record.startdate=Time.zone.local(2022,9,1)
record.location=location
setup_validator.validate_location(record)
expect(record.errors["location_id"]).tobe_empty
end
end
context"with a location with no deactivation periods"do