aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/cache
diff options
context:
space:
mode:
authorMartin <hongzeqin@gmail.com>2018-08-05 22:42:16 +0800
committerRichard Schneeman <richard.schneeman+no-recruiters@gmail.com>2018-08-05 09:42:16 -0500
commit47018a829ceed958c9765ec7678eae476a51c18e (patch)
tree9b9d1af9129d2691e4700180cfa9acd11e7bb7c1 /activesupport/test/cache
parenta2b9768792a81e474a8b70d3950cd14ffd491207 (diff)
downloadrails-47018a829ceed958c9765ec7678eae476a51c18e.tar.gz
rails-47018a829ceed958c9765ec7678eae476a51c18e.tar.bz2
rails-47018a829ceed958c9765ec7678eae476a51c18e.zip
Support skip nil for cache fetch (#25437)
* test case for fetch cache miss with skip_nil * abondon nil cache if skip_nil specified * ensure not cache key for skip nil * add document with skip_nil for Store#fetch * add a new change log entry for #25437
Diffstat (limited to 'activesupport/test/cache')
-rw-r--r--activesupport/test/cache/behaviors/cache_store_behavior.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/activesupport/test/cache/behaviors/cache_store_behavior.rb b/activesupport/test/cache/behaviors/cache_store_behavior.rb
index f9153ffe2a..ae272e87d7 100644
--- a/activesupport/test/cache/behaviors/cache_store_behavior.rb
+++ b/activesupport/test/cache/behaviors/cache_store_behavior.rb
@@ -52,6 +52,13 @@ module CacheStoreBehavior
end
end
+ def test_fetch_cache_miss_with_skip_nil
+ assert_not_called(@cache, :write) do
+ assert_nil @cache.fetch("foo", skip_nil: true) { nil }
+ assert_equal false, @cache.exist?("foo")
+ end
+ end
+
def test_fetch_with_forced_cache_miss_with_block
@cache.write("foo", "bar")
assert_equal "foo_bar", @cache.fetch("foo", force: true) { "foo_bar" }