diff options
author | Neeraj Singh <neerajdotname@gmail.com> | 2010-11-25 01:24:45 +0800 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-11-25 04:38:51 +0800 |
commit | 18adbe9347727dc3eefe46395d52aafa347a0c73 (patch) | |
tree | e94d7b5f781406c21438186b769fdebe513fed4a /actionpack/test | |
parent | 5c9abb6cca4b6de7146c94779a34ae943e4ea4d8 (diff) | |
download | rails-18adbe9347727dc3eefe46395d52aafa347a0c73.tar.gz rails-18adbe9347727dc3eefe46395d52aafa347a0c73.tar.bz2 rails-18adbe9347727dc3eefe46395d52aafa347a0c73.zip |
process text/* if it appears in the middle of
HTTP_ACCEPT parameter
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/dispatch/mime_type_test.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/mime_type_test.rb b/actionpack/test/dispatch/mime_type_test.rb index 25e106f519..9424d88498 100644 --- a/actionpack/test/dispatch/mime_type_test.rb +++ b/actionpack/test/dispatch/mime_type_test.rb @@ -29,6 +29,26 @@ class MimeTypeTest < ActiveSupport::TestCase end end + test "parse text with trailing star at the beginning" do + accept = "text/*, text/html, application/json, multipart/form-data" + expect = [Mime::JSON, Mime::XML, Mime::ICS, Mime::HTML, Mime::CSS, Mime::CSV, Mime::TEXT, Mime::YAML, Mime::JS, Mime::MULTIPART_FORM] + parsed = Mime::Type.parse(accept) + assert_equal expect.size, parsed.size + Range.new(0,expect.size-1).to_a.each do |index| + assert_equal expect[index], parsed[index], "Failed for index number #{index}" + end + end + + test "parse text with trailing star in the end" do + accept = "text/html, application/json, multipart/form-data, text/*" + expect = [Mime::HTML, Mime::JSON, Mime::MULTIPART_FORM, Mime::XML, Mime::ICS, Mime::CSS, Mime::CSV, Mime::JS, Mime::YAML, Mime::TEXT] + parsed = Mime::Type.parse(accept) + assert_equal 10, parsed.size + Range.new(0,expect.size-1).to_a.each do |index| + assert_equal expect[index], parsed[index], "Failed for index number #{index}" + end + end + test "parse text with trailing star" do accept = "text/*" expect = [Mime::JSON, Mime::XML, Mime::ICS, Mime::HTML, Mime::CSS, Mime::CSV, Mime::JS, Mime::YAML, Mime::TEXT].sort_by(&:to_s) |