aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/test/models
diff options
context:
space:
mode:
authorGeorge Claghorn <george.claghorn@gmail.com>2018-05-21 11:49:22 -0400
committerGitHub <noreply@github.com>2018-05-21 11:49:22 -0400
commit6c574ac58993512f975ddaf1f679c5956cc576df (patch)
tree94fdab34c9bcfcba02a3a082f864e8f6107b2d54 /activestorage/test/models
parent41147e3ef802fe7c6aa0eafc9e584fd68f05d395 (diff)
parent0210ac0b430757f2b5ba5e81f4391e6a37b769a4 (diff)
downloadrails-6c574ac58993512f975ddaf1f679c5956cc576df.tar.gz
rails-6c574ac58993512f975ddaf1f679c5956cc576df.tar.bz2
rails-6c574ac58993512f975ddaf1f679c5956cc576df.zip
Merge pull request #32936 from jacobsmith/image-variant-allow-disabling-options
[ActiveStorage] Disable variant options when false or nil present
Diffstat (limited to 'activestorage/test/models')
-rw-r--r--activestorage/test/models/variant_test.rb61
1 files changed, 61 insertions, 0 deletions
diff --git a/activestorage/test/models/variant_test.rb b/activestorage/test/models/variant_test.rb
index e74bbc9ab4..6577f1cd9f 100644
--- a/activestorage/test/models/variant_test.rb
+++ b/activestorage/test/models/variant_test.rb
@@ -25,6 +25,67 @@ class ActiveStorage::VariantTest < ActiveSupport::TestCase
assert_match(/Gray/, image.colorspace)
end
+ test "monochrome with default variant_processor" do
+ begin
+ ActiveStorage.variant_processor = nil
+
+ blob = create_file_blob(filename: "racecar.jpg")
+ variant = blob.variant(monochrome: true).processed
+ image = read_image(variant)
+ assert_match(/Gray/, image.colorspace)
+ ensure
+ ActiveStorage.variant_processor = :mini_magick
+ end
+ end
+
+ test "disabled variation of JPEG blob" do
+ blob = create_file_blob(filename: "racecar.jpg")
+ variant = blob.variant(resize: "100x100", monochrome: false).processed
+ assert_match(/racecar\.jpg/, variant.service_url)
+
+ image = read_image(variant)
+ assert_equal 100, image.width
+ assert_equal 67, image.height
+ assert_match(/RGB/, image.colorspace)
+ end
+
+ test "disabled variation of JPEG blob with :combine_options" do
+ blob = create_file_blob(filename: "racecar.jpg")
+ variant = ActiveSupport::Deprecation.silence do
+ blob.variant(combine_options: {
+ resize: "100x100",
+ monochrome: false
+ }).processed
+ end
+ assert_match(/racecar\.jpg/, variant.service_url)
+
+ image = read_image(variant)
+ assert_equal 100, image.width
+ assert_equal 67, image.height
+ assert_match(/RGB/, image.colorspace)
+ end
+
+ test "disabled variation using :combine_options" do
+ begin
+ ActiveStorage.variant_processor = nil
+ blob = create_file_blob(filename: "racecar.jpg")
+ variant = ActiveSupport::Deprecation.silence do
+ blob.variant(combine_options: {
+ crop: "100x100+0+0",
+ monochrome: false
+ }).processed
+ end
+ assert_match(/racecar\.jpg/, variant.service_url)
+
+ image = read_image(variant)
+ assert_equal 100, image.width
+ assert_equal 100, image.height
+ assert_match(/RGB/, image.colorspace)
+ ensure
+ ActiveStorage.variant_processor = :mini_magick
+ end
+ end
+
test "center-weighted crop of JPEG blob using :combine_options" do
begin
ActiveStorage.variant_processor = nil