Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AS::Cache version upgrading bug #7902

Merged
merged 1 commit into from
Oct 10, 2012

Conversation

josh
Copy link
Contributor

@josh josh commented Oct 10, 2012

Regression from e3a746b

/cc @dhh @bdurand

@dhh
Copy link
Member

dhh commented Oct 10, 2012

Would be nice to have a test for this case.

@josh
Copy link
Contributor Author

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 added a commit that referenced this pull request Oct 10, 2012
@dhh dhh merged commit 1644f12 into rails:master Oct 10, 2012
@josh
Copy link
Contributor Author

josh commented Oct 10, 2012

Dealing with different cache versions seems like a huge pita.

@tenderlove
Copy link
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants