Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #8341 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

[PATCH] Rescuing around_filters broken by #6649

Reported by: codahale Assigned to: nzkoz
Priority: high Milestone: 1.x
Component: ActionPack Version: edge
Severity: major Keywords: test, tiny
Cc:

Description

Any around_filter which was rescuing exceptions raised by the controller action was broken by the recent filters re-write.

Code like this will fail:

class ExceptionHandler
  def filter(controller)
    begin
      yield
    rescue => ex
      controller.send :render, :text => "Oh noes!"
    end
  end
end

Chris Farms' acts_as_friendly_param plugin uses this construction, which is where we're experiencing the failure.

This patch includes failing unit tests and a fix.

The problem appears to be that in #call_filters, only after filters are dealt with once before and around filters have been called. Around filters which have a render operation will show up, but should be simply passed over, rather than raise an exception.

Attachments

fix_rescuing_around_filters.diff (1.9 kB) - added by codahale on 05/11/07 17:35:49.
failing unit tests for the around filter bug and a fix
remove_left_over_around_filters.patch (2.3 kB) - added by skaes on 05/15/07 07:03:58.
improved version of this patch

Change History

05/11/07 17:35:49 changed by codahale

  • attachment fix_rescuing_around_filters.diff added.

failing unit tests for the around filter bug and a fix

05/15/07 07:03:58 changed by skaes

  • attachment remove_left_over_around_filters.patch added.

improved version of this patch

05/15/07 07:05:23 changed by skaes

  • owner changed from core to nzkoz.

the problem with the original version of the patch is that it will hide bugs in the ordering of the filter chain. the new version improves on this.

05/20/07 19:06:03 changed by indirect

  • keywords set to test, tiny.

05/22/07 19:17:48 changed by xal

  • status changed from new to closed.
  • resolution set to fixed.

(In [6810]) Rescuing in around_filters works as expected again [codahale, Stephan Kaes]. Closes #8341