1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

do not test explicit equality of predicate methods, they should be allowed to return truthy or falsey objects

This commit is contained in:
Aaron Patterson 2011-03-07 09:36:07 -08:00
parent a032212e7c
commit 5968d7a658
2 changed files with 4 additions and 8 deletions

View file

@ -590,11 +590,7 @@ module ActiveSupport
# Check if the entry is expired. The +expires_in+ parameter can override the
# value set when the entry was created.
def expired?
if @expires_in && @created_at + @expires_in <= Time.now.to_f
true
else
false
end
@expires_in && @created_at + @expires_in <= Time.now.to_f
end
# Set a new time when the entry will expire.

View file

@ -679,12 +679,12 @@ class CacheEntryTest < ActiveSupport::TestCase
def test_expired
entry = ActiveSupport::Cache::Entry.new("value")
assert_equal false, entry.expired?
assert !entry.expired?, 'entry not expired'
entry = ActiveSupport::Cache::Entry.new("value", :expires_in => 60)
assert_equal false, entry.expired?
assert !entry.expired?, 'entry not expired'
time = Time.now + 61
Time.stubs(:now).returns(time)
assert_equal true, entry.expired?
assert entry.expired?, 'entry is expired'
end
def test_compress_values