Skip to content

Commit

Permalink
Merge pull request #53515 from k-tsuchiya-jp/fix-53467
Browse files Browse the repository at this point in the history
Ensure proper output of traces for dasherized Rails application name
  • Loading branch information
rafaelfranca committed Nov 5, 2024
1 parent a122c47 commit 473f2b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion railties/lib/rails/backtrace_cleaner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

module Rails
class BacktraceCleaner < ActiveSupport::BacktraceCleaner # :nodoc:
APP_DIRS_PATTERN = /\A(?:\.\/)?(?:app|config|lib|test|\(\w*\))/
APP_DIRS_PATTERN = /\A(?:\.\/)?(?:app|config|lib|test|\(\w+(?:-\w+)*\))/
RENDER_TEMPLATE_PATTERN = /:in [`'].*_\w+_{2,3}\d+_\d+'/

def initialize
Expand Down
9 changes: 9 additions & 0 deletions railties/test/backtrace_cleaner_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ def setup
assert_equal 2, result.length
end

test "#clean should consider traces that include dasherized Rails application name" do
backtrace = [ "(my-app):1",
"/Path/to/rails/railties/lib/rails/commands/console.rb:77:in `start'",
"bin/rails:4:in `<main>'" ]
result = @cleaner.clean(backtrace)
assert_equal "(my-app):1", result[0]
assert_equal 1, result.length
end

test "#clean 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}'"]
Expand Down

0 comments on commit 473f2b2

Please # to comment.