diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2017-07-17 07:10:27 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-17 07:10:27 -0600 |
commit | 404eceba8c8f0951407c2508567f6abefec76e4c (patch) | |
tree | cb8c690084083b6aee4a70ad29c24c0050f88bed /activesupport/test/cache/cache_store_logger_test.rb | |
parent | e505bc8acd4448030fd4d2f85796bdb61d45a5b1 (diff) | |
parent | fbade51248ea48db87703ba7418badbd3ed85e36 (diff) | |
download | rails-404eceba8c8f0951407c2508567f6abefec76e4c.tar.gz rails-404eceba8c8f0951407c2508567f6abefec76e4c.tar.bz2 rails-404eceba8c8f0951407c2508567f6abefec76e4c.zip |
Merge branch 'master' into make-reverse-merge-bang-order-consistent
Diffstat (limited to 'activesupport/test/cache/cache_store_logger_test.rb')
-rw-r--r-- | activesupport/test/cache/cache_store_logger_test.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/activesupport/test/cache/cache_store_logger_test.rb b/activesupport/test/cache/cache_store_logger_test.rb new file mode 100644 index 0000000000..1af6893cc9 --- /dev/null +++ b/activesupport/test/cache/cache_store_logger_test.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +require "abstract_unit" +require "active_support/cache" + +class CacheStoreLoggerTest < ActiveSupport::TestCase + def setup + @cache = ActiveSupport::Cache.lookup_store(:memory_store) + + @buffer = StringIO.new + @cache.logger = ActiveSupport::Logger.new(@buffer) + end + + def test_logging + @cache.fetch("foo") { "bar" } + assert @buffer.string.present? + end + + def test_log_with_string_namespace + @cache.fetch("foo", namespace: "string_namespace") { "bar" } + assert_match %r{string_namespace:foo}, @buffer.string + end + + def test_log_with_proc_namespace + proc = Proc.new do + "proc_namespace" + end + @cache.fetch("foo", namespace: proc) { "bar" } + assert_match %r{proc_namespace:foo}, @buffer.string + end + + def test_mute_logging + @cache.mute { @cache.fetch("foo") { "bar" } } + assert @buffer.string.blank? + end +end |