aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-03-07 09:36:07 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2011-03-07 09:36:07 -0800
commit5968d7a65886d3450698889f685eccaf54749f43 (patch)
tree86ce7affa6185046b5df292c9931f853e820e8ac
parenta032212e7c1da834ae75d85a4f2f1f943bfdc474 (diff)
downloadrails-5968d7a65886d3450698889f685eccaf54749f43.tar.gz
rails-5968d7a65886d3450698889f685eccaf54749f43.tar.bz2
rails-5968d7a65886d3450698889f685eccaf54749f43.zip
do not test explicit equality of predicate methods, they should be allowed to return truthy or falsey objects
-rw-r--r--activesupport/lib/active_support/cache.rb6
-rw-r--r--activesupport/test/caching_test.rb6
2 files changed, 4 insertions, 8 deletions
diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb
index e2b7b0707b..10c457bb1d 100644
--- a/activesupport/lib/active_support/cache.rb
+++ b/activesupport/lib/active_support/cache.rb
@@ -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.
diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb
index 579d5dad24..e5668e29d7 100644
--- a/activesupport/test/caching_test.rb
+++ b/activesupport/test/caching_test.rb
@@ -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