Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
3 changed files
with
93 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |