|
|
3f3017 |
diff --git a/actionpack/test/controller/mime/respond_to_test.rb b/actionpack/test/controller/mime/respond_to_test.rb
|
|
|
3f3017 |
index 993f4001de..d113db8b76 100644
|
|
|
3f3017 |
--- a/actionpack/test/controller/mime/respond_to_test.rb
|
|
|
3f3017 |
+++ b/actionpack/test/controller/mime/respond_to_test.rb
|
|
|
3f3017 |
@@ -104,7 +104,7 @@ def made_for_content_type
|
|
|
3f3017 |
def custom_type_handling
|
|
|
3f3017 |
respond_to do |type|
|
|
|
3f3017 |
type.html { render body: "HTML" }
|
|
|
3f3017 |
- type.custom("application/crazy-xml") { render body: "Crazy XML" }
|
|
|
3f3017 |
+ type.custom("application/fancy-xml") { render body: "Fancy XML" }
|
|
|
3f3017 |
type.all { render body: "Nothing" }
|
|
|
3f3017 |
end
|
|
|
3f3017 |
end
|
|
|
3f3017 |
@@ -294,12 +294,14 @@ def setup
|
|
|
3f3017 |
@request.host = "www.example.com"
|
|
|
3f3017 |
Mime::Type.register_alias("text/html", :iphone)
|
|
|
3f3017 |
Mime::Type.register("text/x-mobile", :mobile)
|
|
|
3f3017 |
+ Mime::Type.register("application/fancy-xml", :fancy_xml)
|
|
|
3f3017 |
end
|
|
|
3f3017 |
|
|
|
3f3017 |
def teardown
|
|
|
3f3017 |
super
|
|
|
3f3017 |
Mime::Type.unregister(:iphone)
|
|
|
3f3017 |
Mime::Type.unregister(:mobile)
|
|
|
3f3017 |
+ Mime::Type.unregister(:fancy_xml)
|
|
|
3f3017 |
end
|
|
|
3f3017 |
|
|
|
3f3017 |
def test_html
|
|
|
3f3017 |
@@ -455,10 +457,10 @@ def test_synonyms
|
|
|
3f3017 |
end
|
|
|
3f3017 |
|
|
|
3f3017 |
def test_custom_types
|
|
|
3f3017 |
- @request.accept = "application/crazy-xml"
|
|
|
3f3017 |
+ @request.accept = "application/fancy-xml"
|
|
|
3f3017 |
get :custom_type_handling
|
|
|
3f3017 |
- assert_equal "application/crazy-xml", @response.content_type
|
|
|
3f3017 |
- assert_equal 'Crazy XML', @response.body
|
|
|
3f3017 |
+ assert_equal "application/fancy-xml", @response.content_type
|
|
|
3f3017 |
+ assert_equal "Fancy XML", @response.body
|
|
|
3f3017 |
|
|
|
3f3017 |
@request.accept = "text/html"
|
|
|
3f3017 |
get :custom_type_handling
|
|
|
3f3017 |
diff --git a/actionpack/test/controller/new_base/content_negotiation_test.rb b/actionpack/test/controller/new_base/content_negotiation_test.rb
|
|
|
3f3017 |
index c0e92b3b05..b867bcd675 100644
|
|
|
3f3017 |
--- a/actionpack/test/controller/new_base/content_negotiation_test.rb
|
|
|
3f3017 |
+++ b/actionpack/test/controller/new_base/content_negotiation_test.rb
|
|
|
3f3017 |
@@ -19,9 +19,19 @@ class TestContentNegotiation < Rack::TestCase
|
|
|
3f3017 |
assert_body "Hello world */*!"
|
|
|
3f3017 |
end
|
|
|
3f3017 |
|
|
|
3f3017 |
- test "Not all mimes are converted to symbol" do
|
|
|
3f3017 |
+ test "A js or */* Accept header will return HTML" do
|
|
|
3f3017 |
+ get "/content_negotiation/basic/hello", headers: { "HTTP_ACCEPT" => "text/javascript, */*" }
|
|
|
3f3017 |
+ assert_body "Hello world text/html!"
|
|
|
3f3017 |
+ end
|
|
|
3f3017 |
+
|
|
|
3f3017 |
+ test "A js or */* Accept header on xhr will return HTML" do
|
|
|
3f3017 |
+ get "/content_negotiation/basic/hello", headers: { "HTTP_ACCEPT" => "text/javascript, */*" }, xhr: true
|
|
|
3f3017 |
+ assert_body "Hello world text/javascript!"
|
|
|
3f3017 |
+ end
|
|
|
3f3017 |
+
|
|
|
3f3017 |
+ test "Unregistered mimes are ignored" do
|
|
|
3f3017 |
get "/content_negotiation/basic/all", headers: { "HTTP_ACCEPT" => "text/plain, mime/another" }
|
|
|
3f3017 |
- assert_body '[:text, "mime/another"]'
|
|
|
3f3017 |
+ assert_body '[:text]'
|
|
|
3f3017 |
end
|
|
|
3f3017 |
end
|
|
|
3f3017 |
end
|