From 6351e0a541698bdaca348ad78bc9f7b25f6d56d6 Mon Sep 17 00:00:00 2001 From: Rick Olson Date: Thu, 12 Apr 2007 20:25:32 +0000 Subject: The default respond_to blocks don't set a specific extension anymore, so that both 'show.rjs' and 'show.js.rjs' will work. [Rick] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6517 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/controller/mime_responds_test.rb | 12 +++++++----- actionpack/test/controller/render_test.rb | 6 ++++++ actionpack/test/controller/request_test.rb | 12 +++++++++--- 3 files changed, 22 insertions(+), 8 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb index aa31d5b649..d8d7c64ce0 100644 --- a/actionpack/test/controller/mime_responds_test.rb +++ b/actionpack/test/controller/mime_responds_test.rb @@ -288,11 +288,13 @@ class MimeControllerTest < Test::Unit::TestCase assert_equal 'Either JS or XML', @response.body end - def test_all_types_with_layout + 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 + + def test_html_type_with_layout @request.env["HTTP_ACCEPT"] = "text/html" get :all_types_with_layout assert_equal 'HTML for all_types_with_layout', @response.body @@ -343,14 +345,14 @@ class MimeControllerTest < Test::Unit::TestCase unless args.empty? @action = args.first[:action] end - response.body = @action + response.body = "#{@action} - #{@template.template_format}" end end get :using_defaults - assert_equal "using_defaults", @response.body + assert_equal "using_defaults - html", @response.body get :using_defaults, :format => "xml" - assert_equal "using_defaults.xml.builder", @response.body + assert_equal "using_defaults - xml", @response.body end end diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index 7175b4f798..cba21fc4cb 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -361,6 +361,12 @@ class RenderTest < Test::Unit::TestCase get :formatted_xml_erb assert_equal 'passed formatted html erb', @response.body end + + def test_should_render_formatted_html_erb_template_with_faulty_accepts_header + @request.env["HTTP_ACCEPT"] = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, appliction/x-shockwave-flash, */*" + get :formatted_xml_erb + assert_equal 'passed formatted html erb', @response.body + end protected def assert_deprecated_render(&block) diff --git a/actionpack/test/controller/request_test.rb b/actionpack/test/controller/request_test.rb index 4914df679c..b939f6f975 100644 --- a/actionpack/test/controller/request_test.rb +++ b/actionpack/test/controller/request_test.rb @@ -309,16 +309,22 @@ class RequestTest < Test::Unit::TestCase assert @request.head? end - def test_format + def test_xml_format @request.instance_eval { @parameters = { :format => 'xml' } } assert_equal Mime::XML, @request.format - + end + + def test_xhtml_format @request.instance_eval { @parameters = { :format => 'xhtml' } } assert_equal Mime::HTML, @request.format - + end + + def test_txt_format @request.instance_eval { @parameters = { :format => 'txt' } } assert_equal Mime::TEXT, @request.format + end + def test_nil_format @request.instance_eval { @parameters = { :format => nil } } @request.env["HTTP_ACCEPT"] = "text/javascript" assert_equal Mime::JS, @request.format -- cgit v1.2.3