diff options
author | José Valim <jose.valim@gmail.com> | 2009-07-29 14:32:56 +0200 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2009-07-29 12:06:03 -0700 |
commit | fa0cf663fe6a6393a3ba117505703e587da4ddc5 (patch) | |
tree | e703d42fe75ec0af2c543be0d9626c98fa7e5121 /actionpack/test/controller | |
parent | 09de34ca56598ae5d0302a14715b2a11b6cc9845 (diff) | |
download | rails-fa0cf663fe6a6393a3ba117505703e587da4ddc5.tar.gz rails-fa0cf663fe6a6393a3ba117505703e587da4ddc5.tar.bz2 rails-fa0cf663fe6a6393a3ba117505703e587da4ddc5.zip |
Add a couple more tests to respond_with.
Signed-off-by: Yehuda Katz <wycats@gmail.com>
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/mime_responds_test.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb index 369d683d23..558fc47695 100644 --- a/actionpack/test/controller/mime_responds_test.rb +++ b/actionpack/test/controller/mime_responds_test.rb @@ -508,6 +508,12 @@ class RespondWithController < ActionController::Base end end + def default_overwritten + respond_to do |format| + format.html { render :text => "HTML" } + end + end + protected def _render_js(js, options) @@ -516,6 +522,17 @@ protected end end +class InheritedRespondWithController < RespondWithController + clear_respond_to + respond_to :xml, :json + + def index + respond_with(RespondResource.new) do |format| + format.json { render :text => "JSON" } + end + end +end + class RespondWithControllerTest < ActionController::TestCase tests RespondWithController @@ -590,6 +607,27 @@ class RespondWithControllerTest < ActionController::TestCase assert_equal "JS", @response.body end + def test_default_overwritten + get :default_overwritten + assert_equal "text/html", @response.content_type + assert_equal "HTML", @response.body + end + + def test_clear_respond_to + @controller = InheritedRespondWithController.new + @request.accept = "text/html" + get :index + assert_equal 406, @response.status + end + + def test_first_in_respond_to_has_higher_priority + @controller = InheritedRespondWithController.new + @request.accept = "*/*" + get :index + assert_equal "application/xml", @response.content_type + assert_equal "XML", @response.body + end + def test_not_acceptable @request.accept = "application/xml" get :using_defaults |