diff options
Diffstat (limited to 'actionpack/test/controller/mime_responds_test.rb')
-rw-r--r-- | actionpack/test/controller/mime_responds_test.rb | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb index 8f1c56710f..c4d8709fc3 100644 --- a/actionpack/test/controller/mime_responds_test.rb +++ b/actionpack/test/controller/mime_responds_test.rb @@ -170,18 +170,26 @@ 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 + + get :json_or_yaml, :format => 'json' assert_equal 'JSON', @response.body + + get :json_or_yaml, :format => 'yaml' + assert_equal 'YAML', @response.body + + { 'YAML' => %w(text/yaml), + 'JSON' => %w(application/json text/x-json) + }.each do |body, content_types| + content_types.each do |content_type| + @request.env['HTTP_ACCEPT'] = content_type + get :json_or_yaml + assert_equal body, @response.body + end + end end def test_js_or_anything |