Skip to content

Commit

Permalink
Merge pull request #31 from alphagov/bugfix_for_time_constraint_to_al…
Browse files Browse the repository at this point in the history
…low_launch_dates

Bugfix: allowing launch dates in time constraints
  • Loading branch information
dhwthompson committed Dec 14, 2012
2 parents a692831 + 61f3094 commit 9255f4c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/time_constraint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions test/unit/models/time_constraint_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9255f4c

Please sign in to comment.