Changeset 5695
- Timestamp:
- 12/06/06 23:06:38 (2 years ago)
- Files:
-
- trunk/actionpack/lib/action_controller/mime_types.rb (modified) (2 diffs)
- trunk/actionpack/test/controller/mime_responds_test.rb (modified) (1 diff)
- trunk/actionpack/test/controller/render_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/lib/action_controller/mime_types.rb
r5694 r5695 3 3 Mime::Type.register "text/html", :html, %w( application/xhtml+xml ), %w( xhtml ) 4 4 Mime::Type.register "text/javascript", :js, %w( application/javascript application/x-javascript ) 5 Mime::Type.register "text/x-json", :json, %w( application/x-json )6 5 Mime::Type.register "text/calendar", :ics 7 6 Mime::Type.register "text/csv", :csv … … 10 9 Mime::Type.register "application/atom+xml", :atom 11 10 Mime::Type.register "application/x-yaml", :yaml, %w( text/yaml ) 11 12 # http://www.ietf.org/rfc/rfc4627.txt 13 Mime::Type.register "application/json", :json, %w( text/x-json ) trunk/actionpack/test/controller/mime_responds_test.rb
r5694 r5695 171 171 assert_response 406 172 172 end 173 173 174 174 def test_json_or_yaml 175 175 get :json_or_yaml 176 176 assert_equal 'JSON', @response.body 177 178 @request.env["HTTP_ACCEPT"] = "text/yaml" 179 get :json_or_yaml 177 178 get :json_or_yaml, :format => 'json' 179 assert_equal 'JSON', @response.body 180 181 get :json_or_yaml, :format => 'yaml' 180 182 assert_equal 'YAML', @response.body 181 182 @request.env["HTTP_ACCEPT"] = "text/x-json" 183 get :json_or_yaml 184 assert_equal 'JSON', @response.body 183 184 { 'YAML' => %w(text/yaml), 185 'JSON' => %w(application/json text/x-json) 186 }.each do |body, content_types| 187 content_types.each do |content_type| 188 @request.env['HTTP_ACCEPT'] = content_type 189 get :json_or_yaml 190 assert_equal body, @response.body 191 end 192 end 185 193 end 186 194 trunk/actionpack/test/controller/render_test.rb
r5694 r5695 39 39 render_text "hello world" 40 40 end 41 41 42 42 def render_json_hello_world 43 43 render_json({:hello => 'world'}.to_json) 44 44 end 45 45 46 46 def render_json_hello_world_with_callback 47 47 render_json({:hello => 'world'}.to_json, 'alert') … … 172 172 assert_equal "hello world", @response.body 173 173 end 174 174 175 175 def test_do_with_render_json 176 176 get :render_json_hello_world 177 177 assert_equal '{hello: "world"}', @response.body 178 end 179 178 assert_equal 'application/json', @response.content_type 179 end 180 180 181 def test_do_with_render_json_with_callback 181 182 get :render_json_hello_world_with_callback 182 183 assert_equal 'alert({hello: "world"})', @response.body 184 assert_equal 'application/json', @response.content_type 183 185 end 184 186