-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use #performed?
to terminate controller callbacks
#25079
Use #performed?
to terminate controller callbacks
#25079
Conversation
r? @eileencodes (@rails-bot has picked a reviewer for you, use r? to override) |
f163985
to
889b2a8
Compare
r? @jeremy |
Since 69009f, `ActionController::Metal::DataStreaming#send_file` doesn't set `@_response_body` anymore. `AbstractController::Callbacks` used `@_response_body` in its callback terminator, so it failed to halt the callback cycle when using `#send_file` from a `before_action`. Instead, it now uses `#performed?` on `AbstractController::Base` and `ActionController::Metal`, which checks `response.committed?`, besides checking if `@_response_body` is set, if possible. Example application: https://gist.github.com/jeffkreeftmeijer/78ae4572f36b198e729724b0cf79ef8e
889b2a8
to
f650e03
Compare
@@ -150,6 +150,13 @@ def available_action?(action_name) | |||
_find_action_name(action_name) | |||
end | |||
|
|||
# Tests if a response body is set. Used to determine if the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should document the intention of the method. like just Tests if a response body is set
. It doesn't matter how it was implemented or where it is used internally.
Action view tests are broken. |
Deleting the test. It was added by #17978 which adequately tests the necessary behavior elsewhere. It's failing here because calling |
…st-cycle Use `#performed?` to terminate controller callbacks
…st-cycle Use `#performed?` to terminate controller callbacks
…st-cycle Use `#performed?` to terminate controller callbacks
As (very) briefly discussed with @jeremy: https://twitter.com/bitsweat/status/732983029677719552.
Since 69009f4,
ActionController::Metal::DataStreaming#send_file
doesn'tset
@_response_body
anymore.AbstractController::Callbacks
used@_response_body
in its callbackterminator, so it failed to halt the callback cycle when using
#send_file
from a
before_action
.Instead, it now uses
#performed?
onAbstractController::Base
andActionController::Metal
, which checksresponse.committed?
, besideschecking if
@_response_body
is set, if possible.Example application: https://gist.github.com/jeffkreeftmeijer/78ae4572f36b198e729724b0cf79ef8e