Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #31 from alphagov/bugfix_for_time_constraint_to_al…

…low_launch_dates

Bugfix: allowing launch dates in time constraints
  • Loading branch information...
commit 9255f4cd850d63c626ffccf43bf7dd4b2abba85d 2 parents a692831 + 61f3094
@fatbusinessman fatbusinessman authored
View
2  app/models/time_constraint.rb
@@ -5,5 +5,5 @@ class TimeConstraint < TablelessModel
validates_date :needed_by_date, :allow_nil => true, :allow_blank => true, :on_or_after => :today
validates_date :not_before_date, :allow_nil => true, :allow_blank => true, :on_or_after => :today
- validates_date :not_before_date, :before => :needed_by_date, :unless => Proc.new { |c| c.needed_by_date.blank? || c.not_before_date.blank? }
+ validates_date :not_before_date, :on_or_before => :needed_by_date, :unless => Proc.new { |c| c.needed_by_date.blank? || c.not_before_date.blank? }
end
View
6 test/unit/models/time_constraint_test.rb
@@ -36,4 +36,10 @@ def as_str(date)
should "allow a blank not_before_date if the needed_by_date is set" do
assert TimeConstraint.new(:needed_by_date => as_str(Date.tomorrow)).valid?
end
+
+ should "allow launch dates (i.e. not_before_date = needed_by_date)" do
+ constraint = TimeConstraint.new(not_before_date: as_str(Date.tomorrow),
+ needed_by_date: as_str(Date.tomorrow))
+ assert constraint.valid?
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.