diff options
Diffstat (limited to 'actionpack/test')
-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 |