public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Ensure objects cached with MemoryStore are immutable
josh (author)
Tue Aug 19 17:20:10 -0700 2008
commit  5de340e79f1d11973b7c7bbec82f320fc92b9c99
tree    71673fecc53a7904629424522feafaaca933f2c2
parent  a8ece12fe2ac7838407954453e0d31af6186a5db
...
22
23
24
25
 
26
27
28
...
22
23
24
 
25
26
27
28
0
@@ -22,7 +22,7 @@ module ActiveSupport
0
       def write(name, value, options = nil)
0
         @guard.synchronize do
0
           super
0
-          @data[name] = value
0
+          @data[name] = value.freeze
0
         end
0
       end
0
 
...
120
121
122
 
 
 
 
 
 
123
...
120
121
122
123
124
125
126
127
128
129
0
@@ -120,4 +120,10 @@ class MemoryStoreTest < Test::Unit::TestCase
0
   def test_fetch_with_forced_cache_miss
0
     @cache.fetch('foo', :force => true) { 'bar' }
0
   end
0
+
0
+  def test_store_objects_should_be_immutable
0
+    @cache.write('foo', 'bar')
0
+    assert_raise(ActiveSupport::FrozenObjectError) { @cache.read('foo').gsub!(/.*/, 'baz') }
0
+    assert_equal 'bar', @cache.read('foo')
0
+  end
0
 end

Comments