2017-07-11 12:53:17 -04:00
|
|
|
require "test_helper"
|
|
|
|
require "database/setup"
|
|
|
|
require "active_storage/variant"
|
|
|
|
|
2017-07-21 16:52:09 -04:00
|
|
|
class ActiveStorage::VariantTest < ActiveSupport::TestCase
|
2017-07-21 16:51:31 -04:00
|
|
|
setup do
|
2017-07-21 17:34:18 -04:00
|
|
|
@blob = create_image_blob filename: "racecar.jpg"
|
2017-07-21 16:51:31 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
test "resized variation" do
|
2017-07-21 17:44:10 -04:00
|
|
|
variant = @blob.variant(resize: "100x100").processed
|
|
|
|
|
|
|
|
assert_match /racecar.jpg/, variant.url
|
|
|
|
assert_same_image "racecar-100x100.jpg", variant
|
2017-07-21 16:51:31 -04:00
|
|
|
end
|
2017-07-11 12:53:17 -04:00
|
|
|
|
2017-07-21 16:51:31 -04:00
|
|
|
test "resized and monochrome variation" do
|
2017-07-21 17:44:10 -04:00
|
|
|
variant = @blob.variant(resize: "100x100", monochrome: true).processed
|
|
|
|
|
|
|
|
assert_match /racecar.jpg/, variant.url
|
|
|
|
assert_same_image "racecar-100x100-monochrome.jpg", variant
|
2017-07-11 12:53:17 -04:00
|
|
|
end
|
|
|
|
end
|