Skip to content
Browse files

Merge branch 'master' of github.com:rails/rails

  • Loading branch information...
2 parents 61a31f3 + 0c4990b commit 44587b7faeb2bf2962e9a2e824c341ff1e3f9add @josh josh committed Dec 1, 2009
View
11 actionpack/lib/action_controller/metal/responder.rb
@@ -102,9 +102,14 @@ def initialize(controller, resources, options={})
# not defined, call to_format.
#
def self.call(*args)
- responder = new(*args)
- method = :"to_#{responder.format}"
- responder.respond_to?(method) ? responder.send(method) : responder.to_format
+ new(*args).respond
+ end
+
+ # Main entry point for responder responsible to dispatch to the proper format.
+ #
+ def respond
+ method = :"to_#{format}"
+ respond_to?(method) ? send(method) : to_format
end
# HTML format does not render the resource, it always attempt to render a
View
1 actionpack/test/controller/caching_test.rb
@@ -640,6 +640,7 @@ def test_fragment_for_logging
assert fragment_computed
assert_equal 'generated till now -> ', buffer
+ ActiveSupport::Notifications.notifier.wait
assert_equal [:fragment_exist?, :write_fragment], events.map(&:first)
end
View
17 actionpack/test/controller/mime_responds_test.rb
@@ -507,6 +507,13 @@ def using_resource_with_action
end
end
+ def using_responder_with_respond
+ responder = Class.new(ActionController::Responder) do
+ def respond; @controller.render :text => "respond #{format}"; end
+ end
+ respond_with(Customer.new("david", 13), :responder => responder)
+ end
+
protected
def _render_js(js, options)
@@ -735,6 +742,16 @@ def render(params={})
assert_equal "foo - #{[:html].to_s}", @controller.response_body
end
+ def test_respond_as_responder_entry_point
+ @request.accept = "text/html"
+ get :using_responder_with_respond
+ assert_equal "respond html", @response.body
+
+ @request.accept = "application/xml"
+ get :using_responder_with_respond
+ assert_equal "respond xml", @response.body
+ end
+
def test_clear_respond_to
@controller = InheritedRespondWithController.new
@request.accept = "text/html"

0 comments on commit 44587b7

Please sign in to comment.
Something went wrong with that request. Please try again.