aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-09-17 18:10:25 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-09-17 18:10:25 +0000
commitcaa8a005202b267b75baf521d5f613f3a2bce600 (patch)
treedf72b8673b625b22037895a81b672a8b1650d5a6 /actionpack/test/controller
parent98a412aa3853b9e31b747f53e58a841966df5f1b (diff)
downloadrails-caa8a005202b267b75baf521d5f613f3a2bce600.tar.gz
rails-caa8a005202b267b75baf521d5f613f3a2bce600.tar.bz2
rails-caa8a005202b267b75baf521d5f613f3a2bce600.zip
Added that respond_to blocks will automatically set the content type to be the same as is requested [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5131 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/content_type_test.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/actionpack/test/controller/content_type_test.rb b/actionpack/test/controller/content_type_test.rb
index 71563ba9a6..f2708acc0a 100644
--- a/actionpack/test/controller/content_type_test.rb
+++ b/actionpack/test/controller/content_type_test.rb
@@ -30,6 +30,15 @@ class ContentTypeController < ActionController::Base
render :action => "render_default_for_rxml"
end
+ def render_default_content_types_for_respond_to
+ respond_to do |format|
+ format.html { render :text => "hello world!" }
+ format.xml { render :action => "render_default_content_types_for_respond_to.rhtml" }
+ format.js { render :text => "hello world!" }
+ format.rss { render :text => "hello world!", :content_type => Mime::XML }
+ end
+ end
+
def rescue_action(e) raise end
end
@@ -96,4 +105,26 @@ class ContentTypeTest < Test::Unit::TestCase
assert_equal Mime::HTML, @response.content_type
assert_equal "utf-8", @response.charset
end
+
+ def test_render_default_content_types_for_respond_to
+ @request.env["HTTP_ACCEPT"] = Mime::HTML.to_s
+ get :render_default_content_types_for_respond_to
+ assert_equal Mime::HTML, @response.content_type
+
+ @request.env["HTTP_ACCEPT"] = Mime::JS.to_s
+ get :render_default_content_types_for_respond_to
+ assert_equal Mime::JS, @response.content_type
+ end
+
+ def test_render_default_content_types_for_respond_to_with_template
+ @request.env["HTTP_ACCEPT"] = Mime::XML.to_s
+ get :render_default_content_types_for_respond_to
+ assert_equal Mime::XML, @response.content_type
+ end
+
+ def test_render_default_content_types_for_respond_to_with_overwrite
+ @request.env["HTTP_ACCEPT"] = Mime::RSS.to_s
+ get :render_default_content_types_for_respond_to
+ assert_equal Mime::XML, @response.content_type
+ end
end \ No newline at end of file