diff options
author | Eileen M. Uchitelle <eileencodes@users.noreply.github.com> | 2019-03-19 09:22:16 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-19 09:22:16 -0400 |
commit | 7fe3c69331175a64f01ef64e7afab6d9236fbdbc (patch) | |
tree | d8df19bd0295fe46cd6f311ed47efea016e78bc6 /actionpack/test | |
parent | 969a1416ebbb74ffb50617ae00029308e8d4f176 (diff) | |
parent | b5e8942c95078945ff09a83b2fc03a0ae7e35953 (diff) | |
download | rails-7fe3c69331175a64f01ef64e7afab6d9236fbdbc.tar.gz rails-7fe3c69331175a64f01ef64e7afab6d9236fbdbc.tar.bz2 rails-7fe3c69331175a64f01ef64e7afab6d9236fbdbc.zip |
Merge pull request #35604 from jhawthorn/validate_mime_types
Raise exception when building invalid mime type
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/dispatch/mime_type_test.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/mime_type_test.rb b/actionpack/test/dispatch/mime_type_test.rb index 45d91883c0..bb3d888e30 100644 --- a/actionpack/test/dispatch/mime_type_test.rb +++ b/actionpack/test/dispatch/mime_type_test.rb @@ -174,4 +174,36 @@ class MimeTypeTest < ActiveSupport::TestCase assert_not (Mime[:js] !~ "application/javascript") assert Mime[:html] =~ "application/xhtml+xml" end + + test "can be initialized with wildcards" do + assert_equal "*/*", Mime::Type.new("*/*").to_s + assert_equal "text/*", Mime::Type.new("text/*").to_s + assert_equal "video/*", Mime::Type.new("video/*").to_s + end + + test "invalid mime types raise error" do + assert_raises Mime::Type::InvalidMimeType do + Mime::Type.new("too/many/slash") + end + + assert_raises Mime::Type::InvalidMimeType do + Mime::Type.new("missingslash") + end + + assert_raises Mime::Type::InvalidMimeType do + Mime::Type.new("text/html, text/plain") + end + + assert_raises Mime::Type::InvalidMimeType do + Mime::Type.new("*/html") + end + + assert_raises Mime::Type::InvalidMimeType do + Mime::Type.new("") + end + + assert_raises Mime::Type::InvalidMimeType do + Mime::Type.new(nil) + end + end end |