From 7fc8b6d82cd82440558664e4f2d82d6933d4cba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janko=20Marohni=C4=87?= Date: Mon, 23 Apr 2018 12:21:42 +0200 Subject: Show ImageProcessing macros in a dedicated example --- activestorage/test/models/variant_test.rb | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'activestorage/test/models') diff --git a/activestorage/test/models/variant_test.rb b/activestorage/test/models/variant_test.rb index f6b6579d7d..e74bbc9ab4 100644 --- a/activestorage/test/models/variant_test.rb +++ b/activestorage/test/models/variant_test.rb @@ -6,7 +6,7 @@ require "database/setup" class ActiveStorage::VariantTest < ActiveSupport::TestCase test "resized variation of JPEG blob" do blob = create_file_blob(filename: "racecar.jpg") - variant = blob.variant(resize_to_fit: [100, 100]).processed + variant = blob.variant(resize: "100x100").processed assert_match(/racecar\.jpg/, variant.service_url) image = read_image(variant) @@ -16,7 +16,7 @@ class ActiveStorage::VariantTest < ActiveSupport::TestCase test "resized and monochrome variation of JPEG blob" do blob = create_file_blob(filename: "racecar.jpg") - variant = blob.variant(resize_to_fit: [100, 100], monochrome: true).processed + variant = blob.variant(resize: "100x100", monochrome: true).processed assert_match(/racecar\.jpg/, variant.service_url) image = read_image(variant) @@ -25,7 +25,7 @@ class ActiveStorage::VariantTest < ActiveSupport::TestCase assert_match(/Gray/, image.colorspace) end - test "center-weighted crop of JPEG blob" do + test "center-weighted crop of JPEG blob using :combine_options" do begin ActiveStorage.variant_processor = nil blob = create_file_blob(filename: "racecar.jpg") @@ -46,6 +46,16 @@ class ActiveStorage::VariantTest < ActiveSupport::TestCase end end + test "center-weighted crop of JPEG blob using :resize_to_fill" do + blob = create_file_blob(filename: "racecar.jpg") + variant = blob.variant(resize_to_fill: [100, 100]).processed + assert_match(/racecar\.jpg/, variant.service_url) + + image = read_image(variant) + assert_equal 100, image.width + assert_equal 100, image.height + end + test "resized variation of PSD blob" do blob = create_file_blob(filename: "icon.psd", content_type: "image/vnd.adobe.photoshop") variant = blob.variant(resize: "20x20").processed -- cgit v1.2.3