fix misleading variant test

This commit fixes the "resized variation of BMP blob" test.

By default `create_file_blob` use "image/jpeg" as content type,
since this test does not specify the correct `content_type` for
a `*.bmp` image ("image/bmp") the `ActiveStorage::Variant#specification`
consider the blob as a web image which causes the variant to return a
`*.bmp` URL and a "BMP" type, this is an incorrect behavior since if you
upload a `*.bmp` image the variant will have a PNG format with "image/png"
as content type.

After this change the test will cover the current activestorage behavior.

Changes:

* Specify correct `content_type` on "resized variation of BMP blob" test.
* Change asserts to cover the current activestorage behavior.
This commit is contained in:
Victor Perez Rodriguez 2020-07-29 16:02:32 -05:00
parent fa82ea4098
commit 3eb48a2148

@ -162,12 +162,12 @@ class ActiveStorage::VariantTest < ActiveSupport::TestCase
end
test "resized variation of BMP blob" do
blob = create_file_blob(filename: "colors.bmp")
blob = create_file_blob(filename: "colors.bmp", content_type: "image/bmp")
variant = blob.variant(resize: "15x15").processed
assert_match(/colors\.bmp/, variant.url)
assert_match(/colors\.png/, variant.url)
image = read_image(variant)
assert_equal "BMP", image.type
assert_equal "PNG", image.type
assert_equal 15, image.width
assert_equal 8, image.height
end