提交 658cf556 编写于 作者: J Jeremy Kemper 提交者: Yehuda Katz

Test that exceptions raised in filters are properly rescued

上级 6b3c702b
...@@ -1350,9 +1350,12 @@ def process_cleanup ...@@ -1350,9 +1350,12 @@ def process_cleanup
end end
Base.class_eval do Base.class_eval do
include Flash, Filters, Layout, Benchmarking, Rescue, MimeResponds, Helpers [ Flash, Filters, Layout, Benchmarking, Rescue, MimeResponds, Helpers,
include Cookies, Caching, Verification, Streaming Cookies, Caching, Verification, Streaming, SessionManagement,
include SessionManagement, HttpAuthentication::Basic::ControllerMethods HttpAuthentication::Basic::ControllerMethods, RecordIdentifier,
include RecordIdentifier, RequestForgeryProtection, Translation RequestForgeryProtection, Translation
].each do |mod|
include mod
end
end end
end end
...@@ -67,6 +67,11 @@ class ResourceUnavailableToRescueAsString < StandardError ...@@ -67,6 +67,11 @@ class ResourceUnavailableToRescueAsString < StandardError
render :text => 'no way' render :text => 'no way'
end end
before_filter(:only => :before_filter_raises) { raise 'umm nice' }
def before_filter_raises
end
def raises def raises
render :text => 'already rendered' render :text => 'already rendered'
raise "don't panic!" raise "don't panic!"
...@@ -154,6 +159,16 @@ def populate_exception_object ...@@ -154,6 +159,16 @@ def populate_exception_object
end end
end end
def test_rescue_exceptions_raised_by_filters
with_rails_root FIXTURE_PUBLIC do
with_all_requests_local false do
get :before_filter_raises
end
end
assert_response :internal_server_error
end
def test_rescue_action_locally_if_all_requests_local def test_rescue_action_locally_if_all_requests_local
@controller.expects(:local_request?).never @controller.expects(:local_request?).never
@controller.expects(:rescue_action_locally).with(@exception) @controller.expects(:rescue_action_locally).with(@exception)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册