aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-07-18 11:05:37 -0700
committerJosé Valim <jose.valim@gmail.com>2011-07-18 11:05:37 -0700
commitb475f74da5ec2ac4048f70d9063a1d4c0d63b546 (patch)
treed0b602140f2506ec9480b690b70fa0370805125b
parent8efc0f1f340ef50362b87d428ebff85a2f66cb16 (diff)
parentac81af40c0564edbd7e79e00cf8211557d9a761b (diff)
downloadrails-b475f74da5ec2ac4048f70d9063a1d4c0d63b546.tar.gz
rails-b475f74da5ec2ac4048f70d9063a1d4c0d63b546.tar.bz2
rails-b475f74da5ec2ac4048f70d9063a1d4c0d63b546.zip
Merge pull request #2133 from jstorimer/ensure-status-codes-are-logged-properly
Ensure that status codes are logged properly
-rw-r--r--actionpack/lib/action_controller/base.rb8
-rw-r--r--actionpack/test/controller/log_subscriber_test.rb19
2 files changed, 23 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index d14c5f940b..ce56d8bc71 100644
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -212,16 +212,16 @@ module ActionController
# also include them at the bottom.
AbstractController::Callbacks,
+ # Append rescue at the bottom to wrap as much as possible.
+ Rescue,
+
# Add instrumentations hooks at the bottom, to ensure they instrument
# all the methods properly.
Instrumentation,
# Params wrapper should come before instrumentation so they are
# properly showed in logs
- ParamsWrapper,
-
- # The same with rescue, append it at the end to wrap as much as possible.
- Rescue
+ ParamsWrapper
]
MODULES.each do |mod|
diff --git a/actionpack/test/controller/log_subscriber_test.rb b/actionpack/test/controller/log_subscriber_test.rb
index 80c4fa2ee5..ccdfcb0b2c 100644
--- a/actionpack/test/controller/log_subscriber_test.rb
+++ b/actionpack/test/controller/log_subscriber_test.rb
@@ -6,6 +6,13 @@ module Another
class LogSubscribersController < ActionController::Base
wrap_parameters :person, :include => :name, :format => :json
+ class SpecialException < Exception
+ end
+
+ rescue_from SpecialException do
+ head :status => 406
+ end
+
def show
render :nothing => true
end
@@ -39,6 +46,10 @@ module Another
raise Exception
end
+ def with_rescued_exception
+ raise SpecialException
+ end
+
end
end
@@ -195,6 +206,14 @@ class ACLogSubscriberTest < ActionController::TestCase
assert_match(/Completed 500/, logs.last)
end
+ def test_process_action_with_rescued_exception_includes_http_status_code
+ get :with_rescued_exception
+ wait
+
+ assert_equal 2, logs.size
+ assert_match(/Completed 406/, logs.last)
+ end
+
def logs
@logs ||= @logger.logged(:info)
end