Remove deprecated support to pass `:combine_options` operations to `ActiveStorage::Transformers::ImageProcessing`

This commit is contained in:
Rafael Mendonça França 2020-05-11 13:58:19 -04:00
parent bad3d0f6a3
commit 62bda903be
No known key found for this signature in database
GPG Key ID: FC23B6D0F1EEE948
4 changed files with 13 additions and 46 deletions

View File

@ -1,3 +1,7 @@
* Remove deprecated support to pass `:combine_options` operations to `ActiveStorage::Transformers::ImageProcessing`.
*Rafael Mendonça França*
* Remove deprecated `ActiveStorage::Transformers::MiniMagickTransformer`.
*Rafael Mendonça França*

View File

@ -29,14 +29,13 @@ module ActiveStorage
def operations
transformations.each_with_object([]) do |(name, argument), list|
if name.to_s == "combine_options"
ActiveSupport::Deprecation.warn <<~WARNING.squish
raise ArgumentError, <<~ERROR.squish
Active Storage's ImageProcessing transformer doesn't support :combine_options,
as it always generates a single ImageMagick command. Passing :combine_options will
not be supported in Rails 6.1.
WARNING
as it always generates a single ImageMagick command.
ERROR
end
list.concat argument.keep_if { |key, value| value.present? }.to_a
elsif argument.present?
if argument.present?
list << [ name, argument ]
end
end

View File

@ -60,52 +60,14 @@ class ActiveStorage::VariantTest < ActiveSupport::TestCase
assert_match(/RGB/, image.colorspace)
end
test "disabled variation of JPEG blob with :combine_options" do
test "variation with :combine_options is not supported" do
blob = create_file_blob(filename: "racecar.jpg")
variant = ActiveSupport::Deprecation.silence do
assert_raises(ArgumentError) do
blob.variant(combine_options: {
resize: "100x100",
monochrome: false
}).processed
end
assert_match(/racecar\.jpg/, variant.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
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.url)
image = read_image(variant)
assert_equal 100, image.width
assert_equal 100, image.height
assert_match(/RGB/, image.colorspace)
end
test "center-weighted crop of JPEG blob using :combine_options" do
blob = create_file_blob(filename: "racecar.jpg")
variant = ActiveSupport::Deprecation.silence do
blob.variant(combine_options: {
gravity: "center",
resize: "100x100^",
crop: "100x100+0+0",
}).processed
end
assert_match(/racecar\.jpg/, variant.url)
image = read_image(variant)
assert_equal 100, image.width
assert_equal 100, image.height
end
test "center-weighted crop of JPEG blob using :resize_to_fill" do

View File

@ -243,6 +243,8 @@ Please refer to the [Changelog][active-storage] for detailed changes.
### Removals
* Remove deprecated support to pass `:combine_options` operations to `ActiveStorage::Transformers::ImageProcessing`.
* Remove deprecated `ActiveStorage::Transformers::MiniMagickTransformer`.
* Remove deprecated `config.active_storage.queue`.