aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport')
-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