diff options
Diffstat (limited to 'activestorage/test/models/variant_test.rb')
-rw-r--r-- | activestorage/test/models/variant_test.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/activestorage/test/models/variant_test.rb b/activestorage/test/models/variant_test.rb new file mode 100644 index 0000000000..04ebaccb6a --- /dev/null +++ b/activestorage/test/models/variant_test.rb @@ -0,0 +1,27 @@ +require "test_helper" +require "database/setup" + +class ActiveStorage::VariantTest < ActiveSupport::TestCase + setup do + @blob = create_image_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(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(variant) + assert_equal 100, image.width + assert_equal 67, image.height + assert_match(/Gray/, image.colorspace) + end +end |