提交 0bab6310 编写于 作者: J John Hawthorn

Find query_source_location using lazy Enumerator

This way, we only need to filter the backtrace up to the first non-noise
stack frame.

This also updates noise to be able to deal with being passed a lazy
enum. We don't need this anywhere, but it seemed better for this to be
consistent.
上级 60afbfff
......@@ -110,7 +110,7 @@ def log_query_source
end
def extract_query_source_location(locations)
backtrace_cleaner.clean(locations).first
backtrace_cleaner.clean(locations.lazy).first
end
end
end
......
......@@ -122,7 +122,11 @@ def silence(backtrace)
end
def noise(backtrace)
backtrace - silence(backtrace)
backtrace.select do |line|
@silencers.any? do |s|
s.call(line)
end
end
end
end
end
......@@ -17,6 +17,16 @@ def setup
assert_equal 1, result.length
end
test "can filter for noise" do
backtrace = [ "(irb):1",
"/Path/to/rails/railties/lib/rails/commands/console.rb:77:in `start'",
"bin/rails:4:in `<main>'" ]
result = @cleaner.clean(backtrace, :noise)
assert_equal "/Path/to/rails/railties/lib/rails/commands/console.rb:77:in `start'", result[0]
assert_equal "bin/rails:4:in `<main>'", result[1]
assert_equal 2, result.length
end
test "should omit ActionView template methods names" do
method_name = ActionView::Template.new(nil, "app/views/application/index.html.erb", nil, locals: []).send :method_name
backtrace = [ "app/views/application/index.html.erb:4:in `block in #{method_name}'"]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册