Guard against the case days stale can be negative

This commit is contained in:
Matt Rogers 2013-03-10 22:48:27 -05:00
parent d699359648
commit 053e3fc8d6
2 changed files with 16 additions and 1 deletions

View file

@ -14,6 +14,10 @@ class StalenessTest < Test::Unit::TestCase
@now ||= Time.utc(2013, 2, 28, 0, 0, 0)
end
def after_now
@after_now ||= Time.utc(2013, 3, 1, 0, 0, 0)
end
def day16
@day16 ||= Time.utc(2013, 2, 12, 0, 0, 0)
end
@ -36,6 +40,11 @@ class StalenessTest < Test::Unit::TestCase
assert_equal 0, Staleness.days_stale(todo, @current_user)
end
def test_created_at_after_current_time_is_not_stale
todo = FakeTask.new(nil, false, after_now)
assert_equal 0, Staleness.days_stale(todo, @current_user)
end
def test_young_item_is_not_stale
todo = FakeTask.new(nil, false, now)
assert_equal 0, Staleness.days_stale(todo, @current_user)