From d36f57f430c011e889c7d45335beea4ea0dc9769 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 26 Sep 2012 10:08:20 -0700 Subject: Add logger.push_tags and .pop_tags to complement logger.tagged --- activesupport/test/tagged_logging_test.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'activesupport/test') diff --git a/activesupport/test/tagged_logging_test.rb b/activesupport/test/tagged_logging_test.rb index 43cf1a8e4f..fa045baa28 100644 --- a/activesupport/test/tagged_logging_test.rb +++ b/activesupport/test/tagged_logging_test.rb @@ -29,6 +29,23 @@ 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 -- cgit v1.2.3