diff options
author | José Valim <jose.valim@gmail.com> | 2009-12-01 13:11:24 -0200 |
---|---|---|
committer | Yehuda Katz <wycats@Yehuda-Katz.local> | 2009-12-01 08:23:43 -0800 |
commit | 6e30361260205cb7029fbc78b4a98b66a884ce45 (patch) | |
tree | e76e3a065ce1ff35e3fb092e966d52fc82f5a76f /actionpack/test/controller | |
parent | 6ac32a83283f46b55675ddf4ecab6c91f6f8abde (diff) | |
download | rails-6e30361260205cb7029fbc78b4a98b66a884ce45.tar.gz rails-6e30361260205cb7029fbc78b4a98b66a884ce45.tar.bz2 rails-6e30361260205cb7029fbc78b4a98b66a884ce45.zip |
Allow ActionController::Responder to have a common entry point for all formats.
Signed-off-by: Yehuda Katz <wycats@Yehuda-Katz.local>
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/mime_responds_test.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb index fee9cf46f9..c1fa74b8c8 100644 --- a/actionpack/test/controller/mime_responds_test.rb +++ b/actionpack/test/controller/mime_responds_test.rb @@ -507,6 +507,13 @@ class RespondWithController < ActionController::Base 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 @@ class RespondWithControllerTest < ActionController::TestCase 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" |