aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/debug_exceptions_test.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-10-26 22:04:43 -0500
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-10-26 22:04:43 -0500
commitd27efbfbf5e4426ad50d4479bab08fa4ae051360 (patch)
tree98851f86fa0e91409faf8ce9eb60c41a1b5860b6 /actionpack/test/dispatch/debug_exceptions_test.rb
parentbf17c8a531bc8059d50ad731398002a3e7162a7d (diff)
parentdbcbbcf2bc58e8971672b143d1c52c0244e33f26 (diff)
downloadrails-d27efbfbf5e4426ad50d4479bab08fa4ae051360.tar.gz
rails-d27efbfbf5e4426ad50d4479bab08fa4ae051360.tar.bz2
rails-d27efbfbf5e4426ad50d4479bab08fa4ae051360.zip
Merge pull request #17362 from bronzle/fix_debug_exceptions_app
Show the user’s application in the source window and select the correct ...
Diffstat (limited to 'actionpack/test/dispatch/debug_exceptions_test.rb')
-rw-r--r--actionpack/test/dispatch/debug_exceptions_test.rb42
1 files changed, 41 insertions, 1 deletions
diff --git a/actionpack/test/dispatch/debug_exceptions_test.rb b/actionpack/test/dispatch/debug_exceptions_test.rb
index 0add9fa3b0..f8851f0152 100644
--- a/actionpack/test/dispatch/debug_exceptions_test.rb
+++ b/actionpack/test/dispatch/debug_exceptions_test.rb
@@ -19,6 +19,10 @@ class DebugExceptionsTest < ActionDispatch::IntegrationTest
@closed = true
end
+ def method_that_raises
+ raise StandardError.new 'error in framework'
+ end
+
def call(env)
env['action_dispatch.show_detailed_exceptions'] = @detailed
req = ActionDispatch::Request.new(env)
@@ -57,7 +61,8 @@ class DebugExceptionsTest < ActionDispatch::IntegrationTest
{})
raise ActionView::Template::Error.new(template, e)
end
-
+ when "/framework_raises"
+ method_that_raises
else
raise "puke!"
end
@@ -280,4 +285,39 @@ class DebugExceptionsTest < ActionDispatch::IntegrationTest
assert_select 'pre code', /\(eval\):1: syntax error, unexpected/
end
end
+
+ test 'debug exceptions app shows user code that caused the error in source view' do
+ @app = DevelopmentApp
+ Rails.stubs(:root).returns(Pathname.new('.'))
+ cleaner = ActiveSupport::BacktraceCleaner.new.tap do |bc|
+ bc.add_silencer { |line| line =~ /method_that_raises/ }
+ bc.add_silencer { |line| line !~ %r{test/dispatch/debug_exceptions_test.rb} }
+ end
+
+ get '/framework_raises', {}, {'action_dispatch.backtrace_cleaner' => cleaner}
+
+ # Assert correct error
+ assert_response 500
+ assert_select 'h2', /error in framework/
+
+ # assert source view line is the call to method_that_raises
+ assert_select 'div.source:not(.hidden)' do
+ assert_select 'pre .line.active', /method_that_raises/
+ end
+
+ # assert first source view (hidden) that throws the error
+ assert_select 'div.source:first' do
+ assert_select 'pre .line.active', /raise StandardError\.new/
+ end
+
+ # assert application trace refers to line that calls method_that_raises is first
+ assert_select '#Application-Trace' do
+ assert_select 'pre code a:first', %r{test/dispatch/debug_exceptions_test\.rb:\d+:in `call}
+ end
+
+ # assert framework trace that that threw the error is first
+ assert_select '#Framework-Trace' do
+ assert_select 'pre code a:first', /method_that_raises/
+ end
+ end
end