Active Storage: upgrade to mini_mime 1.1.0

Fix validating uppercase variant formats. Closes #41796.
This commit is contained in:
George Claghorn 2021-04-04 22:44:02 -04:00 committed by GitHub
parent 80bd07a61a
commit b80a2bdeb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 7 deletions

View File

@ -75,7 +75,7 @@ PATH
activerecord (= 7.0.0.alpha)
activesupport (= 7.0.0.alpha)
marcel (~> 1.0.0)
mini_mime (~> 1.0.2)
mini_mime (>= 1.1.0)
activesupport (7.0.0.alpha)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
@ -224,6 +224,9 @@ GEM
tzinfo
event_emitter (0.2.6)
eventmachine (1.2.7)
eventmachine (1.2.7-java)
eventmachine (1.2.7-x64-mingw32)
eventmachine (1.2.7-x86-mingw32)
execjs (2.7.0)
faraday (1.3.0)
faraday-net_http (~> 1.0)
@ -290,12 +293,14 @@ GEM
hiredis (0.6.3)
hiredis (0.6.3-java)
http_parser.rb (0.6.0)
http_parser.rb (0.6.0-java)
httpclient (2.8.3)
i18n (1.8.7)
concurrent-ruby (~> 1.0)
image_processing (1.12.1)
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3)
jar-dependencies (0.4.1)
jdbc-mysql (5.1.47)
jdbc-postgres (42.2.14)
jdbc-sqlite3 (3.28.0)
@ -307,6 +312,7 @@ GEM
mustache
nokogiri
libxml-ruby (3.2.1)
libxml-ruby (3.2.1-x64-mingw32)
listen (3.4.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
@ -319,7 +325,7 @@ GEM
memoist (0.16.2)
method_source (1.0.0)
mini_magick (4.11.0)
mini_mime (1.0.2)
mini_mime (1.1.0)
mini_portile2 (2.5.0)
minitest (5.14.3)
minitest-bisect (1.5.1)
@ -368,6 +374,8 @@ GEM
pg (1.2.3-x64-mingw32)
pg (1.2.3-x86-mingw32)
psych (3.3.0)
psych (3.3.0-java)
jar-dependencies (>= 0.1.7)
public_suffix (4.0.6)
puma (5.1.1)
nio4r (~> 2.0)
@ -636,4 +644,4 @@ DEPENDENCIES
websocket-client-simple!
BUNDLED WITH
2.2.3
2.2.15

View File

@ -37,5 +37,5 @@ Gem::Specification.new do |s|
s.add_dependency "activerecord", version
s.add_dependency "marcel", "~> 1.0.0"
s.add_dependency "mini_mime", "~> 1.0.2"
s.add_dependency "mini_mime", ">= 1.1.0"
end

View File

@ -89,7 +89,7 @@ class ActiveStorage::Variant
end
def filename
ActiveStorage::Filename.new "#{blob.filename.base}.#{variation.format}"
ActiveStorage::Filename.new "#{blob.filename.base}.#{variation.format.downcase}"
end
alias_method :content_type_for_serving, :content_type

View File

@ -33,7 +33,7 @@ class ActiveStorage::VariantWithRecord
def transform_blob
blob.open do |input|
variation.transform(input) do |output|
yield io: output, filename: "#{blob.filename.base}.#{variation.format}",
yield io: output, filename: "#{blob.filename.base}.#{variation.format.downcase}",
content_type: variation.content_type, service_name: blob.service.name
end
end

View File

@ -122,7 +122,7 @@ class ActiveStorage::VariantTest < ActiveSupport::TestCase
end
end
test "PNG variation of JPEG blob" do
test "PNG variation of JPEG blob with lowercase format" do
blob = create_file_blob(filename: "racecar.jpg")
variant = blob.variant(format: :png).processed
assert_equal "racecar.png", variant.filename.to_s
@ -130,6 +130,14 @@ class ActiveStorage::VariantTest < ActiveSupport::TestCase
assert_equal "PNG", read_image(variant).type
end
test "PNG variation of JPEG blob with uppercase format" do
blob = create_file_blob(filename: "racecar.jpg")
variant = blob.variant(format: "PNG").processed
assert_equal "racecar.png", variant.filename.to_s
assert_equal "image/png", variant.content_type
assert_equal "PNG", read_image(variant).type
end
test "variation of invariable blob" do
assert_raises ActiveStorage::InvariableError do
create_file_blob(filename: "report.pdf", content_type: "application/pdf").variant(resize: "100x100")