aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/test/dispatch/mime_type_test.rb28
1 files changed, 27 insertions, 1 deletions
diff --git a/actionpack/test/dispatch/mime_type_test.rb b/actionpack/test/dispatch/mime_type_test.rb
index 4c2b95550c..48755e6b5f 100644
--- a/actionpack/test/dispatch/mime_type_test.rb
+++ b/actionpack/test/dispatch/mime_type_test.rb
@@ -6,10 +6,36 @@ class MimeTypeTest < ActiveSupport::TestCase
test "parse single" do
Mime::LOOKUP.keys.each do |mime_type|
- assert_equal [Mime::Type.lookup(mime_type)], Mime::Type.parse(mime_type)
+ unless image_type == 'image/*'
+ assert_equal [Mime::Type.lookup(mime_type)], Mime::Type.parse(mime_type)
+ end
end
end
+ test "parse text with trailing star star" do
+ accept = "text/*"
+ expect = [Mime::JSON, Mime::XML, Mime::ICS, Mime::HTML, Mime::CSS, Mime::CSV, Mime::JS
+ parsed = Mime::Type.parse(accept)
+ assert_equal 9, parsed.size
+ assert_equal expect, parsed
+ end
+
+ test "parse application with trailing star star" do
+ accept = "application/*"
+ expect = [Mime::HTML, Mime::JS, Mime::XML, Mime::YAML, Mime::ATOM, Mime::JSON, Mime::R
+ parsed = Mime::Type.parse(accept)
+ assert_equal 9, parsed.size
+ assert_equal expect, parsed
+ end
+
+ test "parse image with trailing star star" do
+ accept = "image/*"
+ parsed = Mime::Type.parse(accept)
+ assert_equal 2, parsed.size
+ assert parsed.include?(Mime::PNG)
+ assert_equal 'image/*', parsed[1].instance_variable_get('@string')
+ end
+
test "parse without q" do
accept = "text/xml,application/xhtml+xml,text/yaml,application/xml,text/html,image/png,text/plain,application/pdf,*/*"
expect = [Mime::HTML, Mime::XML, Mime::YAML, Mime::PNG, Mime::TEXT, Mime::PDF, Mime::ALL]