aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-07-01 12:16:55 -0700
committerYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-07-01 12:16:55 -0700
commit1026d7706ffb467eac3cee8142d964bc2d30baa8 (patch)
tree975e8c0440fa39f11eefdf5f63b7b4f42421823b
parent16dc139caa9286638785469304a69ab77e4fe9b5 (diff)
downloadrails-1026d7706ffb467eac3cee8142d964bc2d30baa8.tar.gz
rails-1026d7706ffb467eac3cee8142d964bc2d30baa8.tar.bz2
rails-1026d7706ffb467eac3cee8142d964bc2d30baa8.zip
Original cache objects should not be immutable [#2860 state:resolved]
Signed-off-by: Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>
-rw-r--r--activesupport/lib/active_support/cache/memory_store.rb2
-rw-r--r--activesupport/test/caching_test.rb6
2 files changed, 7 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/cache/memory_store.rb b/activesupport/lib/active_support/cache/memory_store.rb
index 1b30d49155..21ba79cf3d 100644
--- a/activesupport/lib/active_support/cache/memory_store.rb
+++ b/activesupport/lib/active_support/cache/memory_store.rb
@@ -26,7 +26,7 @@ module ActiveSupport
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)
diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb
index c2a03818e1..928af256f4 100644
--- a/activesupport/test/caching_test.rb
+++ b/activesupport/test/caching_test.rb
@@ -176,6 +176,12 @@ class MemoryStoreTest < ActiveSupport::TestCase
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