mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fixed new callbacks to not call the action when a callback sets the response body
This commit is contained in:
parent
22c5667c2e
commit
72ca7c591c
2 changed files with 20 additions and 1 deletions
|
@ -5,7 +5,7 @@ module AbstractController
|
|||
depends_on ActiveSupport::NewCallbacks
|
||||
|
||||
included do
|
||||
define_callbacks :process_action
|
||||
define_callbacks :process_action, "response_body"
|
||||
end
|
||||
|
||||
def process_action
|
||||
|
|
|
@ -193,5 +193,24 @@ module AbstractController
|
|||
end
|
||||
end
|
||||
|
||||
class SetsResponseBody < ControllerWithCallbacks
|
||||
before_filter :set_body
|
||||
|
||||
def index
|
||||
self.response_body = "Fail"
|
||||
end
|
||||
|
||||
def set_body
|
||||
self.response_body = "Success"
|
||||
end
|
||||
end
|
||||
|
||||
class TestHalting < ActiveSupport::TestCase
|
||||
test "when a callback sets the response body, the action should not be invoked" do
|
||||
result = SetsResponseBody.process(:index)
|
||||
assert_equal "Success", result.response_body
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue