2017-08-12 08:32:15 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-07-11 12:53:17 -04:00
|
|
|
require "test_helper"
|
|
|
|
require "database/setup"
|
|
|
|
|
2017-07-21 16:52:09 -04:00
|
|
|
class ActiveStorage::VariantTest < ActiveSupport::TestCase
|
2017-07-21 16:51:31 -04:00
|
|
|
setup do
|
2017-09-28 16:43:37 -04:00
|
|
|
@blob = create_file_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
|
2017-08-14 09:17:50 -04:00
|
|
|
assert_match(/racecar\.jpg/, variant.service_url)
|
2017-07-26 14:58:59 -04:00
|
|
|
|
2017-09-28 16:43:37 -04:00
|
|
|
image = read_image(variant)
|
2017-07-26 14:58:59 -04:00
|
|
|
assert_equal 100, image.width
|
|
|
|
assert_equal 67, image.height
|
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
|
2017-08-14 09:17:50 -04:00
|
|
|
assert_match(/racecar\.jpg/, variant.service_url)
|
2017-07-26 14:58:59 -04:00
|
|
|
|
2017-09-28 16:43:37 -04:00
|
|
|
image = read_image(variant)
|
2017-07-26 14:58:59 -04:00
|
|
|
assert_equal 100, image.width
|
|
|
|
assert_equal 67, image.height
|
2017-08-04 23:21:21 -04:00
|
|
|
assert_match(/Gray/, image.colorspace)
|
2017-07-11 12:53:17 -04:00
|
|
|
end
|
|
|
|
end
|