aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/mime_responds_test.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-03-12 06:02:44 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-03-12 06:02:44 +0000
commit7af12d04cebe3a1ffcf55cae967d22fc7b0606c8 (patch)
tree2c3345004b15682c6344126c3bfe49c8a4f79a15 /actionpack/test/controller/mime_responds_test.rb
parent9e2932f816b0cac68361bb5adcdad3e4c3caeb04 (diff)
downloadrails-7af12d04cebe3a1ffcf55cae967d22fc7b0606c8.tar.gz
rails-7af12d04cebe3a1ffcf55cae967d22fc7b0606c8.tar.bz2
rails-7af12d04cebe3a1ffcf55cae967d22fc7b0606c8.zip
Added synonym and custom type handling to respond_to [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3844 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller/mime_responds_test.rb')
-rw-r--r--actionpack/test/controller/mime_responds_test.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb
index 184110aad1..1470fa9899 100644
--- a/actionpack/test/controller/mime_responds_test.rb
+++ b/actionpack/test/controller/mime_responds_test.rb
@@ -56,6 +56,14 @@ class RespondToController < ActionController::Base
end
end
+ def custom_type_handling
+ respond_to do |type|
+ type.html { render :text => "HTML" }
+ type.custom("application/crazy-xml") { render :text => "Crazy XML" }
+ type.all { render :text => "Nothing" }
+ end
+ end
+
def rescue_action(e)
raise unless ActionController::MissingTemplate === e
end
@@ -155,4 +163,24 @@ class MimeControllerTest < Test::Unit::TestCase
get :made_for_content_type
assert_equal "RSS", @response.body
end
+
+ def test_synonyms
+ @request.env["HTTP_ACCEPT"] = "application/javascript"
+ get :js_or_html
+ assert_equal 'JS', @response.body
+
+ @request.env["HTTP_ACCEPT"] = "application/x-xml"
+ get :using_argument_defaults
+ assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<person>\n <name>David</name>\n</person>\n", @response.body
+ end
+
+ def test_custom_types
+ @request.env["HTTP_ACCEPT"] = "application/crazy-xml"
+ get :custom_type_handling
+ assert_equal 'Crazy XML', @response.body
+
+ @request.env["HTTP_ACCEPT"] = "text/html"
+ get :custom_type_handling
+ assert_equal 'HTML', @response.body
+ end
end \ No newline at end of file