aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/caching_test.rb
diff options
context:
space:
mode:
authorJeremy Daer <jeremydaer@gmail.com>2016-04-18 08:16:50 -0700
committerJeremy Daer <jeremydaer@gmail.com>2016-04-18 08:35:55 -0700
commitb39131e8bdb65a9ee51e49d7fe8f058e702e173b (patch)
tree82525d1e79ca4bc22f99256a5bad10bad21b20fe /activesupport/test/caching_test.rb
parent71657146374595b6b9b04916649922fa4f5f512d (diff)
parenta712acc42543b575a623e1a8880c0e9dd5505cfa (diff)
downloadrails-b39131e8bdb65a9ee51e49d7fe8f058e702e173b.tar.gz
rails-b39131e8bdb65a9ee51e49d7fe8f058e702e173b.tar.bz2
rails-b39131e8bdb65a9ee51e49d7fe8f058e702e173b.zip
Merge pull request #24577 from mechanicles/fix-fetch-cache-miss
Fix forced cache miss for fetch when called without a block.
Diffstat (limited to 'activesupport/test/caching_test.rb')
-rw-r--r--activesupport/test/caching_test.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb
index 9e744afb2b..ec7d028d7e 100644
--- a/activesupport/test/caching_test.rb
+++ b/activesupport/test/caching_test.rb
@@ -266,6 +266,20 @@ module CacheStoreBehavior
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' }
+ end
+
+ def test_fetch_with_forced_cache_miss_without_block
+ @cache.write('foo', 'bar')
+ assert_raises(ArgumentError) do
+ @cache.fetch('foo', force: true)
+ end
+
+ assert_equal 'bar', @cache.read('foo')
+ end
+
def test_should_read_and_write_hash
assert @cache.write('foo', {:a => "b"})
assert_equal({:a => "b"}, @cache.read('foo'))