aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/log_subscriber_test.rb
diff options
context:
space:
mode:
authorJesse Storimer <jstorimer@gmail.com>2011-07-18 13:37:23 -0400
committerJesse Storimer <jstorimer@gmail.com>2011-07-18 13:42:07 -0400
commitac81af40c0564edbd7e79e00cf8211557d9a761b (patch)
tree82e6f05af197113267c7029248056f14d7137e45 /actionpack/test/controller/log_subscriber_test.rb
parentda144894e958770c84692065ec260aea2853afe9 (diff)
downloadrails-ac81af40c0564edbd7e79e00cf8211557d9a761b.tar.gz
rails-ac81af40c0564edbd7e79e00cf8211557d9a761b.tar.bz2
rails-ac81af40c0564edbd7e79e00cf8211557d9a761b.zip
Ensure that status codes are logged properly
Needed to move AC::Metal::Instrumentation before AM::Metal::Rescue so that status codes rendered from rescue_from blocks are logged properly.
Diffstat (limited to 'actionpack/test/controller/log_subscriber_test.rb')
-rw-r--r--actionpack/test/controller/log_subscriber_test.rb19
1 files changed, 19 insertions, 0 deletions
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