aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2018-08-15 20:16:43 +0200
committerGitHub <noreply@github.com>2018-08-15 20:16:43 +0200
commit977d77e9e250a323f64785042d9ad8412368c19a (patch)
tree8f0e67b907628ed40fc683e8c4bad473ce8a32df /activesupport/test
parentefaa7191f24da079e785b00019a9ef252f841a8c (diff)
parentc675783eb4fb42a357ec068d4cfd83bf08f78aea (diff)
downloadrails-977d77e9e250a323f64785042d9ad8412368c19a.tar.gz
rails-977d77e9e250a323f64785042d9ad8412368c19a.tar.bz2
rails-977d77e9e250a323f64785042d9ad8412368c19a.zip
Merge pull request #33499 from lsylvester/caller-ignore-paths
use BacktraceCleaner for ActiveRecord verbose logging
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/clean_backtrace_test.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/activesupport/test/clean_backtrace_test.rb b/activesupport/test/clean_backtrace_test.rb
index 1b44c7c9bf..a0a7056952 100644
--- a/activesupport/test/clean_backtrace_test.rb
+++ b/activesupport/test/clean_backtrace_test.rb
@@ -74,3 +74,43 @@ class BacktraceCleanerFilterAndSilencerTest < ActiveSupport::TestCase
assert_equal [ "/class.rb" ], @bc.clean([ "/mongrel/class.rb" ])
end
end
+
+class BacktraceCleanerDefaultFilterAndSilencerTest < ActiveSupport::TestCase
+ def setup
+ @bc = ActiveSupport::BacktraceCleaner.new
+ end
+
+ test "should format installed gems correctly" do
+ backtrace = [ "#{Gem.default_dir}/gems/nosuchgem-1.2.3/lib/foo.rb" ]
+ result = @bc.clean(backtrace, :all)
+ assert_equal "nosuchgem (1.2.3) lib/foo.rb", result[0]
+ end
+
+ test "should format installed gems not in Gem.default_dir correctly" do
+ target_dir = Gem.path.detect { |p| p != Gem.default_dir }
+ # skip this test if default_dir is the only directory on Gem.path
+ if target_dir
+ backtrace = [ "#{target_dir}/gems/nosuchgem-1.2.3/lib/foo.rb" ]
+ result = @bc.clean(backtrace, :all)
+ assert_equal "nosuchgem (1.2.3) lib/foo.rb", result[0]
+ end
+ end
+
+ test "should format gems installed by bundler" do
+ backtrace = [ "#{Gem.default_dir}/bundler/gems/nosuchgem-1.2.3/lib/foo.rb" ]
+ result = @bc.clean(backtrace, :all)
+ assert_equal "nosuchgem (1.2.3) lib/foo.rb", result[0]
+ end
+
+ test "should silence gems from the backtrace" do
+ backtrace = [ "#{Gem.path[0]}/gems/nosuchgem-1.2.3/lib/foo.rb" ]
+ result = @bc.clean(backtrace)
+ assert_empty result
+ end
+
+ test "should silence stdlib" do
+ backtrace = ["#{RbConfig::CONFIG["rubylibdir"]}/lib/foo.rb"]
+ result = @bc.clean(backtrace)
+ assert_empty result
+ end
+end