mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Fixed new callbacks to not call the action when a callback sets the response body
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user