From ddd0a22133e3aff87f9a966af3ddf85c41f42d2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Mon, 29 Dec 2014 17:13:47 -0300 Subject: Check by @v before converting the entry on expired? We should convert when @v is defined not @value. The test was calling value first that already converts the entry so we are not catching this bug. --- activesupport/lib/active_support/cache.rb | 2 +- activesupport/test/caching_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index ff67a6828c..d49cd7988f 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -622,7 +622,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? - convert_version_4beta1_entry! if defined?(@value) + convert_version_4beta1_entry! if defined?(@v) @expires_in && @created_at + @expires_in <= Time.now.to_f end diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb index 5945605f7b..24cd33b8af 100644 --- a/activesupport/test/caching_test.rb +++ b/activesupport/test/caching_test.rb @@ -1070,7 +1070,7 @@ class CacheEntryTest < ActiveSupport::TestCase version_4beta1_entry.instance_variable_set(:@v, "hello") version_4beta1_entry.instance_variable_set(:@x, Time.now.to_i - 1) entry = Marshal.load(Marshal.dump(version_4beta1_entry)) - assert_equal "hello", entry.value assert_equal true, entry.expired? + assert_equal "hello", entry.value end end -- cgit v1.2.3