mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
a22bb8fa69
This is a follow up to https://github.com/rails/rails/pull/42227#issuecomment-1100927828 The mime types database was incorrect regarding `image/bmp`. It has been fixed in https://github.com/mime-types/mime-types-data/issues/48 and in https://github.com/discourse/mini_mime/pull/45 Since a new version of `mini_mime` hasn't been cut yet, some of the tests in this PR look a bit off. But the core issue of not warning users if they use `image/bmp` is resolved.
40 lines
1.6 KiB
Ruby
40 lines
1.6 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require "test_helper"
|
|
require "database/setup"
|
|
|
|
class ActiveStorage::EngineTest < ActiveSupport::TestCase
|
|
test "all default content types are recognized by mini_mime" do
|
|
exceptions = ActiveStorage::Blob::INVALID_VARIABLE_CONTENT_TYPES_DEPRECATED_IN_RAILS_7 +
|
|
ActiveStorage::Blob::INVALID_VARIABLE_CONTENT_TYPES_TO_SERVE_AS_BINARY_DEPRECATED_IN_RAILS_7 +
|
|
["image/bmp"] # see https://github.com/discourse/mini_mime/pull/45, once mini_mime is updated this can be removed
|
|
|
|
ActiveStorage.variable_content_types.each do |content_type|
|
|
next if exceptions.include?(content_type) # remove this line in Rails 7.1
|
|
|
|
assert_equal content_type, MiniMime.lookup_by_content_type(content_type)&.content_type
|
|
end
|
|
|
|
ActiveStorage.web_image_content_types.each do |content_type|
|
|
next if exceptions.include?(content_type) # remove this line in Rails 7.1
|
|
|
|
assert_equal content_type, MiniMime.lookup_by_content_type(content_type)&.content_type
|
|
end
|
|
|
|
ActiveStorage.content_types_to_serve_as_binary.each do |content_type|
|
|
next if exceptions.include?(content_type) # remove this line in Rails 7.1
|
|
|
|
assert_equal content_type, MiniMime.lookup_by_content_type(content_type)&.content_type
|
|
end
|
|
|
|
ActiveStorage.content_types_allowed_inline.each do |content_type|
|
|
next if exceptions.include?(content_type) # remove this line in Rails 7.1
|
|
|
|
assert_equal content_type, MiniMime.lookup_by_content_type(content_type)&.content_type
|
|
end
|
|
end
|
|
|
|
test "image/bmp is a default content type" do
|
|
assert_includes ActiveStorage.variable_content_types, "image/bmp"
|
|
end
|
|
end
|