Changeset 8987
- Timestamp:
- 03/07/08 11:17:05 (2 months ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/mime_responds.rb (modified) (2 diffs)
- trunk/actionpack/test/controller/mime_responds_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r8986 r8987 1 1 *SVN* 2 3 * Make MimeResponds::Responder#any work without explicit types. Closes #11140 [jaw6] 2 4 3 5 * Better error message for type conflicts when parsing params. Closes #7962 [spicycode, matt] trunk/actionpack/lib/action_controller/mime_responds.rb
r8027 r8987 126 126 @order << mime_type 127 127 128 @responses[mime_type] = Proc.new do128 @responses[mime_type] ||= Proc.new do 129 129 @response.template.template_format = mime_type.to_sym 130 130 @response.content_type = mime_type.to_s … … 134 134 135 135 def any(*args, &block) 136 args.each { |type| send(type, &block) } 136 if args.any? 137 args.each { |type| send(type, &block) } 138 else 139 custom(@mime_type_priority.first, &block) 140 end 137 141 end 138 142 trunk/actionpack/test/controller/mime_responds_test.rb
r8683 r8987 106 106 type.html { render :text => "HTML" } 107 107 type.any(:js, :xml) { render :text => "Either JS or XML" } 108 end 109 end 110 111 def handle_any_any 112 respond_to do |type| 113 type.html { render :text => 'HTML' } 114 type.any { render :text => 'Whatever you ask for, I got it' } 108 115 end 109 116 end … … 334 341 get :handle_any 335 342 assert_equal 'Either JS or XML', @response.body 343 end 344 345 def test_handle_any_any 346 @request.env["HTTP_ACCEPT"] = "*/*" 347 get :handle_any_any 348 assert_equal 'HTML', @response.body 349 end 350 351 def test_handle_any_any_parameter_format 352 get :handle_any_any, {:format=>'html'} 353 assert_equal 'HTML', @response.body 354 end 355 356 def test_handle_any_any_explicit_html 357 @request.env["HTTP_ACCEPT"] = "text/html" 358 get :handle_any_any 359 assert_equal 'HTML', @response.body 360 end 361 362 def test_handle_any_any_javascript 363 @request.env["HTTP_ACCEPT"] = "text/javascript" 364 get :handle_any_any 365 assert_equal 'Whatever you ask for, I got it', @response.body 366 end 367 368 def test_handle_any_any_xml 369 @request.env["HTTP_ACCEPT"] = "text/xml" 370 get :handle_any_any 371 assert_equal 'Whatever you ask for, I got it', @response.body 336 372 end 337 373