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

Test that exceptions raised in filters are properly rescued

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