diff options
author | Rick Olson <technoweenie@gmail.com> | 2007-02-15 16:25:46 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2007-02-15 16:25:46 +0000 |
commit | 5d54b8f07cef29e932e164e23713a71274c78e49 (patch) | |
tree | 75b6df90d0364b86b47e1a2a25196c73bd34d7b2 /actionpack/test/controller | |
parent | 5b7630e17423f6c906fb4438766463b25c6fc133 (diff) | |
download | rails-5d54b8f07cef29e932e164e23713a71274c78e49.tar.gz rails-5d54b8f07cef29e932e164e23713a71274c78e49.tar.bz2 rails-5d54b8f07cef29e932e164e23713a71274c78e49.zip |
Add Mime::Type convenience methods to check the current mime type. [Rick]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6152 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/mime_type_test.rb | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/actionpack/test/controller/mime_type_test.rb b/actionpack/test/controller/mime_type_test.rb index 65acbbf36e..0755f9d62d 100644 --- a/actionpack/test/controller/mime_type_test.rb +++ b/actionpack/test/controller/mime_type_test.rb @@ -1,8 +1,8 @@ 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") + Mime::Type.register "image/png", :png + Mime::Type.register "text/plain", :plain def test_parse_single Mime::LOOKUP.keys.each do |mime_type| @@ -30,4 +30,18 @@ class MimeTypeTest < Test::Unit::TestCase end Mime.send :remove_const, :GIF end + + def test_type_convenience_methods + types = [:html, :xml, :png, :plain, :yaml] + types.each do |type| + mime = Mime.const_get(type.to_s.upcase) + assert mime.send("#{type}?"), "Mime::#{type.to_s.upcase} is not #{type}?" + (types - [type]).each { |t| assert !mime.send("#{t}?"), "Mime::#{t.to_s.upcase} is #{t}?" } + end + end + + def test_mime_all_is_html + assert Mime::ALL.all?, "Mime::ALL is not all?" + assert Mime::ALL.html?, "Mime::ALL is not html?" + end end
\ No newline at end of file |