diff options
author | Jamis Buck <jamis@37signals.com> | 2006-03-18 06:15:28 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2006-03-18 06:15:28 +0000 |
commit | 4e0028fbaba3b0497ba5a0fbf0cd314137b7aa8f (patch) | |
tree | 44bc56bae1b5b4321dffe27eb9987eca48b68874 /actionpack/test | |
parent | 263479b5a344e5882f4941e3f18faf9f027b0615 (diff) | |
download | rails-4e0028fbaba3b0497ba5a0fbf0cd314137b7aa8f.tar.gz rails-4e0028fbaba3b0497ba5a0fbf0cd314137b7aa8f.tar.bz2 rails-4e0028fbaba3b0497ba5a0fbf0cd314137b7aa8f.zip |
Make Mime::Type.parse consider q values (if any)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3917 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/mime_type_test.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/actionpack/test/controller/mime_type_test.rb b/actionpack/test/controller/mime_type_test.rb new file mode 100644 index 0000000000..aa1d4459ee --- /dev/null +++ b/actionpack/test/controller/mime_type_test.rb @@ -0,0 +1,24 @@ +require File.dirname(__FILE__) + '/../abstract_unit' + +class MimeTypeTest < Test::Unit::TestCase + Mime::PNG = Mime::Type.new("image/png") + Mime::PLAIN = Mime::Type.new("text/plain") + + def test_parse_single + Mime::LOOKUP.keys.each do |mime_type| + assert_equal [Mime::Type.lookup(mime_type)], Mime::Type.parse(mime_type) + end + end + + def test_parse_without_q + accept = "text/xml,application/xhtml+xml,text/yaml,application/xml,text/html,image/png,text/plain,*/*" + expect = [Mime::HTML, Mime::XML, Mime::YAML, Mime::PNG, Mime::PLAIN, Mime::ALL] + assert_equal expect, Mime::Type.parse(accept) + end + + def test_parse_with_q + accept = "text/xml,application/xhtml+xml,text/yaml; q=0.3,application/xml,text/html; q=0.8,image/png,text/plain; q=0.5,*/*; q=0.2" + expect = [Mime::HTML, Mime::XML, Mime::PNG, Mime::PLAIN, Mime::YAML, Mime::ALL] + assert_equal expect, Mime::Type.parse(accept) + end +end
\ No newline at end of file |