Changeset 6810
- Timestamp:
- 05/22/07 19:17:43 (1 year ago)
- Files:
-
- trunk/actionpack/lib/action_controller/filters.rb (modified) (1 diff)
- trunk/actionpack/test/controller/filters_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/lib/action_controller/filters.rb
r6670 r6810 714 714 return index if aborted || nesting != 0 715 715 716 # if an around filter catches an exception during rendering and handles it, e.g. 717 # by rendering an error page, we might have left over around filters in the filter 718 # chain. so skip over these. 719 index = index.next while (filter = chain[index]) && filter.type == :around 720 716 721 # run after filters, if any 717 722 while chain[index] trunk/actionpack/test/controller/filters_test.rb
r6669 r6810 323 323 def show 324 324 render :text => 'hello' 325 end 326 end 327 328 class ErrorToRescue < Exception; end 329 330 class RescuingAroundFilterWithBlock 331 def filter(controller) 332 begin 333 yield 334 rescue ErrorToRescue => ex 335 controller.send :render, :text => "I rescued this: #{ex.inspect}" 336 end 337 end 338 end 339 340 class RescuedController < ActionController::Base 341 around_filter RescuingAroundFilterWithBlock.new 342 343 def show 344 raise ErrorToRescue.new("Something made the bad noise.") 345 end 346 347 private 348 def rescue_action(exception) 349 raise exception 325 350 end 326 351 end … … 491 516 def test_changing_the_requirements 492 517 assert_equal nil, test_process(ChangingTheRequirementsController, "go_wild").template.assigns['ran_filter'] 518 end 519 520 def test_a_rescuing_around_filter 521 response = nil 522 assert_nothing_raised do 523 response = test_process(RescuedController) 524 end 525 526 assert response.success? 527 assert_equal("I rescued this: #<FilterTest::ErrorToRescue: Something made the bad noise.>", response.body) 493 528 end 494 529