Checking blank if tag might coming nil or blank

In log it should not show the empty array.
This commit is contained in:
Arun Agrawal 2011-10-21 15:12:00 +05:30
parent af1b5c54cf
commit c495cbcda9
2 changed files with 7 additions and 1 deletions

View File

@ -1,3 +1,4 @@
require 'active_support/core_ext/object/blank'
require 'logger'
module ActiveSupport
@ -18,7 +19,7 @@ module ActiveSupport
def tagged(*new_tags)
tags = current_tags
new_tags = Array.wrap(new_tags).flatten
new_tags = Array.wrap(new_tags).flatten.reject(&:blank?)
tags.concat new_tags
yield
ensure

View File

@ -29,6 +29,11 @@ class TaggedLoggingTest < ActiveSupport::TestCase
assert_equal "[BCX] [Jason] [New] 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
end
test "keeps each tag in their own thread" do
@logger.tagged("BCX") do
Thread.new do