From 3baad88c9fa6eefc47bad3d990cdeb04567634b9 Mon Sep 17 00:00:00 2001 From: Doug Alcorn Date: Sat, 27 Mar 2010 12:47:39 -0400 Subject: [PATCH] ActiveSupport::BacktraceCleaner#remove_filters! allows for completely untouched backtrace --- .../lib/active_support/backtrace_cleaner.rb | 8 +++++++- activesupport/test/clean_backtrace_test.rb | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/activesupport/lib/active_support/backtrace_cleaner.rb b/activesupport/lib/active_support/backtrace_cleaner.rb index 6fab565..8465bc1 100644 --- a/activesupport/lib/active_support/backtrace_cleaner.rb +++ b/activesupport/lib/active_support/backtrace_cleaner.rb @@ -4,7 +4,9 @@ module ActiveSupport # context, so only the relevant lines are included. # # If you need to reconfigure an existing BacktraceCleaner, like the one in Rails, to show as much as possible, you can always - # call BacktraceCleaner#remove_silencers! + # call BacktraceCleaner#remove_silencers! Also, if you need to reconfigure an existing BacktraceCleaner so that it does not + # filter or modify the paths of any lines of the backtrace, you can call BacktraceCleaner#remove_filters! These two methods + # will give you a completely untouched backtrace. # # Example: # @@ -60,6 +62,10 @@ module ActiveSupport @silencers = [] end + def remove_filters! + @filters = [] + end + private def filter(backtrace) @filters.each do |f| diff --git a/activesupport/test/clean_backtrace_test.rb b/activesupport/test/clean_backtrace_test.rb index ddbc258..86838a7 100644 --- a/activesupport/test/clean_backtrace_test.rb +++ b/activesupport/test/clean_backtrace_test.rb @@ -9,6 +9,11 @@ class BacktraceCleanerFilterTest < ActiveSupport::TestCase test "backtrace should not contain prefix when it has been filtered out" do assert_equal "/my/class.rb", @bc.clean([ "/my/prefix/my/class.rb" ]).first end + + test "backtrace cleaner should allow removing filters" do + @bc.remove_filters! + assert_equal "/my/prefix/my/class.rb", @bc.clean(["/my/prefix/my/class.rb"]).first + end test "backtrace should contain unaltered lines if they dont match a filter" do assert_equal "/my/other_prefix/my/class.rb", @bc.clean([ "/my/other_prefix/my/class.rb" ]).first @@ -44,4 +49,4 @@ class BacktraceCleanerFilterAndSilencerTest < ActiveSupport::TestCase test "backtrace should not silence lines that has first had their silence hook filtered out" do assert_equal [ "/class.rb" ], @bc.clean([ "/mongrel/class.rb" ]) end -end \ No newline at end of file +end -- 1.7.0