Permalink
Browse files

test for text/*, application/* and image/*

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent d04a21b commit b798a59bd582d8590d4fb8df44885d41cd5299f3 Neeraj Singh committed with josevalim Nov 22, 2010
Showing with 27 additions and 1 deletion.
  1. +27 −1 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]

0 comments on commit b798a59

Please sign in to comment.