aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/caching_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/test/caching_test.rb')
-rw-r--r--activesupport/test/caching_test.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb
index 9f76f4c90b..ed903746c8 100644
--- a/activesupport/test/caching_test.rb
+++ b/activesupport/test/caching_test.rb
@@ -83,7 +83,7 @@ class CacheKeyTest < ActiveSupport::TestCase
def test_expand_cache_key_of_true
assert_equal 'true', ActiveSupport::Cache.expand_cache_key(true)
end
-
+
def test_expand_cache_key_of_array_like_object
assert_equal 'foo/bar/baz', ActiveSupport::Cache.expand_cache_key(%w{foo bar baz}.to_enum)
end
@@ -197,6 +197,16 @@ module CacheStoreBehavior
assert_equal 'baz', @cache.fetch('foo') { 'baz' }
end
+ def test_fetch_with_cache_miss_passes_key_to_block
+ cache_miss = false
+ assert_equal 3, @cache.fetch('foo') { |key| cache_miss = true; key.length }
+ assert cache_miss
+
+ cache_miss = false
+ assert_equal 3, @cache.fetch('foo') { |key| cache_miss = true; key.length }
+ assert !cache_miss
+ end
+
def test_fetch_with_forced_cache_miss
@cache.write('foo', 'bar')
@cache.expects(:read).never
@@ -594,7 +604,7 @@ class FileStoreTest < ActiveSupport::TestCase
assert_equal "views/index?id=1", @cache_with_pathname.send(:file_path_key, key)
end
- # Test that generated cache keys are short enough to have Tempfile stuff added to them and
+ # Test that generated cache keys are short enough to have Tempfile stuff added to them and
# remain valid
def test_filename_max_size
key = "#{'A' * ActiveSupport::Cache::FileStore::FILENAME_MAX_SIZE}"