1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Test actual transformations

This commit is contained in:
David Heinemeier Hansson 2017-07-21 16:44:10 -05:00
parent fa33ec9e7d
commit e9cf92cc39
3 changed files with 15 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
test/fixtures/files/racecar-100x100.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View file

@ -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