diff options
author | Neeraj Singh <neerajdotname@gmail.com> | 2010-11-22 11:27:26 -0500 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-11-22 23:06:13 +0100 |
commit | b798a59bd582d8590d4fb8df44885d41cd5299f3 (patch) | |
tree | a0aab4a3b7bce4048850b470e31fd45d60e95dc5 /actionpack/test | |
parent | d04a21b36281a0608cdd72c02e4df3b1136f8887 (diff) | |
download | rails-b798a59bd582d8590d4fb8df44885d41cd5299f3.tar.gz rails-b798a59bd582d8590d4fb8df44885d41cd5299f3.tar.bz2 rails-b798a59bd582d8590d4fb8df44885d41cd5299f3.zip |
test for text/*, application/* and image/*
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/dispatch/mime_type_test.rb | 28 |
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] |