blob: b7d20ab55a8659addf2b1f94ff1ea2b7f02599c5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# frozen_string_literal: true
require "test_helper"
require "database/setup"
class ActiveStorage::VariantTest < ActiveSupport::TestCase
setup do
@blob = create_file_blob filename: "racecar.jpg"
end
test "resized variation" do
variant = @blob.variant(resize: "100x100").processed
assert_match(/racecar\.jpg/, variant.service_url)
image = read_image(variant)
assert_equal 100, image.width
assert_equal 67, image.height
end
test "resized and monochrome variation" do
variant = @blob.variant(resize: "100x100", monochrome: true).processed
assert_match(/racecar\.jpg/, variant.service_url)
image = read_image(variant)
assert_equal 100, image.width
assert_equal 67, image.height
assert_match(/Gray/, image.colorspace)
end
test "service_url doesn't grow in length despite long variant options" do
variant = @blob.variant(font: "a" * 10_000).processed
assert_operator variant.service_url.length, :<, 500
end
end
|