diff options
author | Robin Clowers <robin.clowers@gmail.com> | 2015-08-30 18:12:58 -0700 |
---|---|---|
committer | Robin Clowers <robin.clowers@gmail.com> | 2015-09-14 20:07:58 -0700 |
commit | a948490b9c9dc31afb3ece482fb6dafb76c34225 (patch) | |
tree | 349e009e146f4d495b3ffe8bac264f41b755b7f6 /activesupport | |
parent | 29886d93048a4719872e228894559b477f87a278 (diff) | |
download | rails-a948490b9c9dc31afb3ece482fb6dafb76c34225.tar.gz rails-a948490b9c9dc31afb3ece482fb6dafb76c34225.tar.bz2 rails-a948490b9c9dc31afb3ece482fb6dafb76c34225.zip |
Add test cases for Cache#fetch instrumentation
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/test/caching_test.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb index 74ceff44f9..c235dee5e1 100644 --- a/activesupport/test/caching_test.rb +++ b/activesupport/test/caching_test.rb @@ -490,6 +490,34 @@ module CacheStoreBehavior assert_equal({key => "bar"}, @cache.read_multi(key)) assert @cache.delete(key) end + + def test_cache_hit_instrumentation + key = "test_key" + subscribe_executed = false + ActiveSupport::Notifications.subscribe "cache_read.active_support" do |name, start, finish, id, payload| + subscribe_executed = true + assert_equal :fetch, payload[:super_operation] + assert payload[:hit] + end + assert @cache.write(key, "1", :raw => true) + assert @cache.fetch(key) {} + assert subscribe_executed + ensure + ActiveSupport::Notifications.unsubscribe "cache_read.active_support" + end + + def test_cache_miss_instrumentation + subscribe_executed = false + ActiveSupport::Notifications.subscribe "cache_read.active_support" do |name, start, finish, id, payload| + subscribe_executed = true + assert_equal :fetch, payload[:super_operation] + assert_not payload[:hit] + end + assert_not @cache.fetch("bad_key") {} + assert subscribe_executed + ensure + ActiveSupport::Notifications.unsubscribe "cache_read.active_support" + end end # https://rails.lighthouseapp.com/projects/8994/tickets/6225-memcachestore-cant-deal-with-umlauts-and-special-characters |