From 46f73da7815b9ee9c84d871ef50a356d849161a3 Mon Sep 17 00:00:00 2001 From: "Scott W. Bradley" Date: Sat, 7 Aug 2010 12:56:45 -0700 Subject: [PATCH] Objects returned from MemoryStore cache should not be frozen, they should be duplicates. This makes Rails.cache.read behave the same for MemoryStore as it does for MemCacheStore. --- activesupport/lib/active_support/cache/memory_store.rb | 2 +- activesupport/test/caching_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/activesupport/lib/active_support/cache/memory_store.rb b/activesupport/lib/active_support/cache/memory_store.rb index 35cc0099431ca..6858e1f19a289 100644 --- a/activesupport/lib/active_support/cache/memory_store.rb +++ b/activesupport/lib/active_support/cache/memory_store.rb @@ -27,7 +27,7 @@ def read_multi(*names) def read(name, options = nil) super - @data[name] + @data[name].duplicable? ? @data[name].dup : @data[name] end def write(name, value, options = nil) diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb index d17448ff135fb..34224e15ae326 100644 --- a/activesupport/test/caching_test.rb +++ b/activesupport/test/caching_test.rb @@ -165,7 +165,7 @@ def setup def test_store_objects_should_be_immutable @cache.write('foo', 'bar') - assert_raise(ActiveSupport::FrozenObjectError) { @cache.read('foo').gsub!(/.*/, 'baz') } + @cache.read('foo').gsub!(/.*/, 'baz') assert_equal 'bar', @cache.read('foo') end