Browse Source

remove unneeded validations

pull/683/head
Dushan Despotovic 3 years ago
parent
commit
c27ec25415
  1. 5
      app/models/validations/date_validations.rb
  2. 13
      spec/models/validations/date_validations_spec.rb

5
app/models/validations/date_validations.rb

@ -35,11 +35,6 @@ module Validations::DateValidations
record.errors.add :startdate, I18n.t("validations.date.outside_collection_window") record.errors.add :startdate, I18n.t("validations.date.outside_collection_window")
end end
if record.startdate < Time.zone.today - 14
record.errors.add :startdate, I18n.t("validations.setup.startdate.later_than_or_14_days_before")
end
if record.scheme_id.present? if record.scheme_id.present?
scheme_end_date = Scheme.find(record.scheme_id).end_date scheme_end_date = Scheme.find(record.scheme_id).end_date
if scheme_end_date.present? && (record.startdate > scheme_end_date) if scheme_end_date.present? && (record.startdate > scheme_end_date)

13
spec/models/validations/date_validations_spec.rb

@ -33,19 +33,6 @@ RSpec.describe Validations::DateValidations do
expect(record.errors["startdate"]).to be_empty expect(record.errors["startdate"]).to be_empty
end end
it "validates that the tenancy start date is later than or 14 days before the current date" do
record.startdate = Time.zone.today - 15.days
setup_validator.validate_startdate(record)
expect(record.errors["startdate"])
.to include(match I18n.t("validations.setup.startdate.later_than_or_14_days_before"))
end
it "produces no error when the tenancy start date is later than or 14 days before the current date" do
record.startdate = Time.zone.today - 7.days
setup_validator.validate_startdate(record)
expect(record.errors["startdate"]).to be_empty
end
it "validates that the tenancy start date is before the end date of the chosen scheme if it has an end date" do it "validates that 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 - 3.days record.startdate = Time.zone.today - 3.days
record.scheme = scheme record.scheme = scheme

Loading…
Cancel
Save