diff options
Diffstat (limited to 'activesupport/test/tagged_logging_test.rb')
-rw-r--r-- | activesupport/test/tagged_logging_test.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/activesupport/test/tagged_logging_test.rb b/activesupport/test/tagged_logging_test.rb index c838c073e6..7253eb1222 100644 --- a/activesupport/test/tagged_logging_test.rb +++ b/activesupport/test/tagged_logging_test.rb @@ -29,6 +29,33 @@ class TaggedLoggingTest < ActiveSupport::TestCase assert_equal "[BCX] [Jason] [New] Funky time\n", @output.string end + test "tagged are flattened" do + @logger.tagged("BCX", %w(Jason New)) { @logger.info "Funky time" } + assert_equal "[BCX] [Jason] [New] Funky time\n", @output.string + end + + test "push and pop tags directly" do + assert_equal %w(A B C), @logger.push_tags('A', ['B', ' ', ['C']]) + @logger.info 'a' + assert_equal %w(C), @logger.pop_tags + @logger.info 'b' + assert_equal %w(B), @logger.pop_tags(1) + @logger.info 'c' + assert_equal [], @logger.clear_tags! + @logger.info 'd' + assert_equal "[A] [B] [C] a\n[A] [B] b\n[A] c\nd\n", @output.string + end + + test "does not strip message content" do + @logger.info " Hello" + assert_equal " Hello\n", @output.string + end + + test "provides access to the logger instance" do + @logger.tagged("BCX") { |logger| logger.info "Funky time" } + assert_equal "[BCX] Funky time\n", @output.string + end + test "tagged once with blank and nil" do @logger.tagged(nil, "", "New") { @logger.info "Funky time" } assert_equal "[New] Funky time\n", @output.string |