diff options
author | Joshua Peek <josh@joshpeek.com> | 2008-08-18 20:14:56 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-08-18 20:17:08 -0500 |
commit | a4da8175a2c989104de1a38e43d5ddfb0f89b055 (patch) | |
tree | 5446ffe7473aaf8f2275e792a3237df4d011ada6 /activesupport/test/caching_test.rb | |
parent | cd8e653d5b18e6d3c3acc9930832f8e23945e392 (diff) | |
download | rails-a4da8175a2c989104de1a38e43d5ddfb0f89b055.tar.gz rails-a4da8175a2c989104de1a38e43d5ddfb0f89b055.tar.bz2 rails-a4da8175a2c989104de1a38e43d5ddfb0f89b055.zip |
Replace MemoryStore mutex with a monitor to avoid issues with nested calls
Diffstat (limited to 'activesupport/test/caching_test.rb')
-rw-r--r-- | activesupport/test/caching_test.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb index c5f7fb7fdd..ce27b464f8 100644 --- a/activesupport/test/caching_test.rb +++ b/activesupport/test/caching_test.rb @@ -97,3 +97,27 @@ class FileStoreTest < Test::Unit::TestCase File.delete("foo.cache") end end + +class MemoryStoreTest < Test::Unit::TestCase + def setup + @cache = ActiveSupport::Cache.lookup_store(:memory_store) + end + + def test_should_read_and_write + @cache.write('foo', 'bar') + assert_equal 'bar', @cache.read('foo') + end + + def test_fetch_without_cache_miss + @cache.write('foo', 'bar') + assert_equal 'bar', @cache.fetch('foo') { 'baz' } + end + + def test_fetch_with_cache_miss + assert_equal 'baz', @cache.fetch('foo') { 'baz' } + end + + def test_fetch_with_forced_cache_miss + @cache.fetch('foo', :force => true) { 'bar' } + end +end |