Permalink
Browse files

Fixed new callbacks to not call the action when a callback sets the r…

…esponse body
  • Loading branch information...
1 parent 22c5667 commit 72ca7c591c9eace150c0ebab1633d691a1ef12cf Yehuda Katz + Carl Lerche committed May 12, 2009
@@ -5,7 +5,7 @@ module Callbacks
depends_on ActiveSupport::NewCallbacks
included do
- define_callbacks :process_action
+ define_callbacks :process_action, "response_body"
end
def process_action
@@ -193,5 +193,24 @@ class TestCallbacks < ActiveSupport::TestCase
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

0 comments on commit 72ca7c5

Please sign in to comment.