diff --git a/test/fixtures/files/racecar-100x100-monochrome.jpg b/test/fixtures/files/racecar-100x100-monochrome.jpg new file mode 100644 index 0000000000..39e683747e Binary files /dev/null and b/test/fixtures/files/racecar-100x100-monochrome.jpg differ diff --git a/test/fixtures/files/racecar-100x100.jpg b/test/fixtures/files/racecar-100x100.jpg new file mode 100644 index 0000000000..2a515a4912 Binary files /dev/null and b/test/fixtures/files/racecar-100x100.jpg differ diff --git a/test/variant_test.rb b/test/variant_test.rb index 0368960fbf..e41842a80c 100644 --- a/test/variant_test.rb +++ b/test/variant_test.rb @@ -8,10 +8,23 @@ class ActiveStorage::VariantTest < ActiveSupport::TestCase end test "resized variation" do - assert_match /racecar.jpg/, @blob.variant(resize: "100x100").processed.url + variant = @blob.variant(resize: "100x100").processed + + assert_match /racecar.jpg/, variant.url + assert_same_image "racecar-100x100.jpg", variant end test "resized and monochrome variation" do - assert_match /racecar.jpg/, @blob.variant(resize: "100x100", monochrome: true).processed.url + variant = @blob.variant(resize: "100x100", monochrome: true).processed + + assert_match /racecar.jpg/, variant.url + assert_same_image "racecar-100x100-monochrome.jpg", variant end + + private + def assert_same_image(fixture_filename, variant) + assert_equal \ + File.binread(File.expand_path("../fixtures/files/#{fixture_filename}", __FILE__)), + File.binread(variant.service.send(:path_for, variant.key)) + end end