diff options
Diffstat (limited to 'actionpack/test/controller/mime_responds_test.rb')
-rw-r--r-- | actionpack/test/controller/mime_responds_test.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb index 1d7fdc0052..8f1c56710f 100644 --- a/actionpack/test/controller/mime_responds_test.rb +++ b/actionpack/test/controller/mime_responds_test.rb @@ -19,6 +19,13 @@ class RespondToController < ActionController::Base type.all { render :text => "Nothing" } end end + + def json_or_yaml + respond_to do |type| + type.json { render :text => "JSON" } + type.yaml { render :yaml => "YAML" } + end + end def html_or_xml respond_to do |type| @@ -163,6 +170,19 @@ class MimeControllerTest < Test::Unit::TestCase get :just_xml assert_response 406 end + + def test_json_or_yaml + get :json_or_yaml + assert_equal 'JSON', @response.body + + @request.env["HTTP_ACCEPT"] = "text/yaml" + get :json_or_yaml + assert_equal 'YAML', @response.body + + @request.env["HTTP_ACCEPT"] = "text/x-json" + get :json_or_yaml + assert_equal 'JSON', @response.body + end def test_js_or_anything @request.env["HTTP_ACCEPT"] = "text/javascript, */*" |