mirror of
https://github.com/github/rails.git
synced 2026-04-04 03:00:58 -04:00
Ensure objects cached with MemoryStore are immutable
This commit is contained in:
@@ -22,7 +22,7 @@ module ActiveSupport
|
||||
def write(name, value, options = nil)
|
||||
@guard.synchronize do
|
||||
super
|
||||
@data[name] = value
|
||||
@data[name] = value.freeze
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -120,4 +120,10 @@ class MemoryStoreTest < Test::Unit::TestCase
|
||||
def test_fetch_with_forced_cache_miss
|
||||
@cache.fetch('foo', :force => true) { 'bar' }
|
||||
end
|
||||
|
||||
def test_store_objects_should_be_immutable
|
||||
@cache.write('foo', 'bar')
|
||||
assert_raise(ActiveSupport::FrozenObjectError) { @cache.read('foo').gsub!(/.*/, 'baz') }
|
||||
assert_equal 'bar', @cache.read('foo')
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user