test/controller/mime_responds_test.rb in actionpack-2.0.5 vs test/controller/mime_responds_test.rb in actionpack-2.1.0

- old
+ new

@@ -1,6 +1,6 @@ -require File.dirname(__FILE__) + '/../abstract_unit' +require 'abstract_unit' class RespondToController < ActionController::Base layout :set_layout def html_xml_or_rss @@ -105,10 +105,17 @@ respond_to do |type| type.html { render :text => "HTML" } type.any(:js, :xml) { render :text => "Either JS or XML" } end end + + def handle_any_any + respond_to do |type| + type.html { render :text => 'HTML' } + type.any { render :text => 'Whatever you ask for, I got it' } + end + end def all_types_with_layout respond_to do |type| type.html type.js @@ -333,10 +340,39 @@ @request.env["HTTP_ACCEPT"] = "text/xml" get :handle_any assert_equal 'Either JS or XML', @response.body end + def test_handle_any_any + @request.env["HTTP_ACCEPT"] = "*/*" + get :handle_any_any + assert_equal 'HTML', @response.body + end + + def test_handle_any_any_parameter_format + get :handle_any_any, {:format=>'html'} + assert_equal 'HTML', @response.body + end + + def test_handle_any_any_explicit_html + @request.env["HTTP_ACCEPT"] = "text/html" + get :handle_any_any + assert_equal 'HTML', @response.body + end + + def test_handle_any_any_javascript + @request.env["HTTP_ACCEPT"] = "text/javascript" + get :handle_any_any + assert_equal 'Whatever you ask for, I got it', @response.body + end + + def test_handle_any_any_xml + @request.env["HTTP_ACCEPT"] = "text/xml" + get :handle_any_any + assert_equal 'Whatever you ask for, I got it', @response.body + end + def test_rjs_type_skips_layout @request.env["HTTP_ACCEPT"] = "text/javascript" get :all_types_with_layout assert_equal 'RJS for all_types_with_layout', @response.body end @@ -430,19 +466,15 @@ def test_format_with_custom_response_type_and_request_headers_with_only_one_layout_present get :iphone_with_html_response_type_without_layout assert_equal '<html><div id="html_missing">Hello future from Firefox!</div></html>', @response.body @request.env["HTTP_ACCEPT"] = "text/iphone" - assert_raises(ActionController::MissingTemplate) { get :iphone_with_html_response_type_without_layout } + assert_raises(ActionView::MissingTemplate) { get :iphone_with_html_response_type_without_layout } end end class AbstractPostController < ActionController::Base - class << self - def view_paths - [ File.dirname(__FILE__) + "/../fixtures/post_test/" ] - end - end + self.view_paths = File.dirname(__FILE__) + "/../fixtures/post_test/" end # For testing layouts which are set automatically class PostController < AbstractPostController around_filter :with_iphone