2017-08-14 13:08:09 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-06 13:16:09 -04:00
|
|
|
require "abstract_unit"
|
|
|
|
require "rails/backtrace_cleaner"
|
2008-11-24 05:25:28 -05:00
|
|
|
|
2016-07-01 19:33:26 -04:00
|
|
|
class BacktraceCleanerTest < ActiveSupport::TestCase
|
2012-05-02 06:56:13 -04:00
|
|
|
def setup
|
|
|
|
@cleaner = Rails::BacktraceCleaner.new
|
|
|
|
end
|
|
|
|
|
2016-07-01 19:33:26 -04:00
|
|
|
test "should consider traces from irb lines as User code" do
|
2018-08-06 01:40:49 -04:00
|
|
|
backtrace = [ "(irb):1",
|
|
|
|
"/Path/to/rails/railties/lib/rails/commands/console.rb:77:in `start'",
|
|
|
|
"bin/rails:4:in `<main>'" ]
|
|
|
|
result = @cleaner.clean(backtrace)
|
|
|
|
assert_equal "(irb):1", result[0]
|
|
|
|
assert_equal 1, result.length
|
2016-07-01 19:33:26 -04:00
|
|
|
end
|
2018-08-06 23:17:01 -04:00
|
|
|
|
|
|
|
test "should omit ActionView template methods names" do
|
|
|
|
method_name = ActionView::Template.new(nil, "app/views/application/index.html.erb", nil, {}).send :method_name
|
|
|
|
backtrace = [ "app/views/application/index.html.erb:4:in `block in #{method_name}'"]
|
|
|
|
result = @cleaner.clean(backtrace, :all)
|
|
|
|
assert_equal "app/views/application/index.html.erb:4", result[0]
|
|
|
|
end
|
2009-03-05 15:48:56 -05:00
|
|
|
end
|