mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Test that exceptions raised in filters are properly rescued
This commit is contained in:
committed by
Yehuda Katz
parent
6b3c702bd7
commit
658cf556d2
@@ -1350,9 +1350,12 @@ module ActionController #:nodoc:
|
||||
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 RescueController < ActionController::Base
|
||||
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 @@ class RescueControllerTest < ActionController::TestCase
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user