Fix AS::Cache version upgrading bug #7902

Merged
merged 1 commit into from Oct 10, 2012

Projects

None yet

3 participants

@josh
Member
josh commented Oct 10, 2012

Regression from e3a746b

/cc @dhh @bdurand

@dhh
Member
dhh commented Oct 10, 2012

Would be nice to have a test for this case.

@josh
Member
josh commented Oct 10, 2012

I really have no idea how to reproduce it with a test case.

It just bombs with an existing tmp/cache running sprockets after that commit.

@dhh dhh merged commit 1644f12 into rails:master Oct 10, 2012
@josh
Member
josh commented Oct 10, 2012

Dealing with different cache versions seems like a huge pita.

@tenderlove
Member
diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb
index febf0ee..9f76f4c 100644
--- a/activesupport/test/caching_test.rb
+++ b/activesupport/test/caching_test.rb
@@ -3,6 +3,20 @@ require 'abstract_unit'
 require 'active_support/cache'

 class CacheKeyTest < ActiveSupport::TestCase
+  def test_entry_legacy_optional_ivars
+    legacy = Class.new(ActiveSupport::Cache::Entry) do
+      def initialize(value, options = {})
+        @value = value
+        @expires_in = nil
+        @created_at = nil
+        super
+      end
+    end
+
+    entry = legacy.new 'foo'
+    assert_equal 'foo', entry.value
+  end
+
   def test_expand_cache_key
     assert_equal '1/2/true', ActiveSupport::Cache.expand_cache_key([1, '2', true])
     assert_equal 'name/1/2/true', ActiveSupport::Cache.expand_cache_key([1, '2', true], :name)

Dealing with different cache versions seems like a huge pita.

We should probably add a version ivar to objects that can be serialized similar to what Rubgems does for gem specifications. That would make updating easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment