Permalink
Browse files

Original cache objects should not be immutable [#2860 state:resolved]

Signed-off-by: Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>
  • Loading branch information...
1 parent 16dc139 commit 1026d7706ffb467eac3cee8142d964bc2d30baa8 Yehuda Katz + Carl Lerche committed Jul 1, 2009
Showing with 7 additions and 1 deletion.
  1. +1 −1 activesupport/lib/active_support/cache/memory_store.rb
  2. +6 −0 activesupport/test/caching_test.rb
@@ -26,7 +26,7 @@ def read(name, options = nil)
def write(name, value, options = nil)
super
- @data[name] = value.freeze
+ @data[name] = (value.duplicable? ? value.dup : value).freeze
end
def delete(name, options = nil)
@@ -176,6 +176,12 @@ def test_store_objects_should_be_immutable
assert_raise(ActiveSupport::FrozenObjectError) { @cache.read('foo').gsub!(/.*/, 'baz') }
assert_equal 'bar', @cache.read('foo')
end
+
+ def test_original_store_objects_should_not_be_immutable
+ bar = 'bar'
+ @cache.write('foo', bar)
+ assert_nothing_raised { bar.gsub!(/.*/, 'baz') }
+ end
end
uses_memcached 'memcached backed store' do

0 comments on commit 1026d77

Please sign in to comment.