Skip to content

Commit

Permalink
Deprecate using Paperclip as Image/Taxon attachment adapter
Browse files Browse the repository at this point in the history
We are also providing a message with instructions for who wants
to keep using Paperclip.

We are silencing deprecation warnings when setting the deprecated
configuration in the CI. This will allow us to keep testing if our
code still works with the deprecated adapter.
  • Loading branch information
kennyadsl committed May 30, 2023
1 parent 825bdfd commit 6837264
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
25 changes: 25 additions & 0 deletions core/lib/spree/app_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,18 @@ def payment_canceller
# @return [Module] a module that can be included into Spree::Image to allow attachments
# Enumerable of images adhering to the present_image_class interface
class_name_attribute :image_attachment_module, default: "Spree::Image::ActiveStorageAttachment"
def image_attachment_module=(value)
if value == 'Spree::Image::PaperclipAttachment'
Spree::Deprecation.warn <<~MSG
Solidus will remove built-in support for Paperclip as image adapter in the next major version.
Please, use the provided generator to incorporate the current Paperclip adapter in your application with:
bin/rails g solidus:paperclip_adapter:install
MSG
end

preferences[:image_attachment_module] = value
end

# @!attribute [rw] allowed_image_mime_types
#
Expand Down Expand Up @@ -558,6 +570,19 @@ def payment_canceller
# @return [Module] a module that can be included into Spree::Taxon to allow attachments
# Enumerable of taxons adhering to the present_taxon_class interface
class_name_attribute :taxon_attachment_module, default: "Spree::Taxon::ActiveStorageAttachment"
def image_attachment_module=(value)
if value == 'Spree::Taxon::PaperclipAttachment'
Spree::Deprecation.warn <<~MSG
Solidus will remove built-in support for Paperclip as taxons' image adapter in the next major version.
Please, use the provided generator to incorporate the current Paperclip adapter in your application with:
bin/rails g solidus:paperclip_adapter:install
MSG
end

preferences[:image_attachment_module] = value
end


# Configures the absolute path that contains the Solidus engine
# migrations. This will be checked at app boot to confirm that all Solidus
Expand Down
6 changes: 4 additions & 2 deletions core/lib/spree/testing_support/dummy_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,10 @@ class Application < ::Rails::Application
Spree.load_defaults(Spree.solidus_version)
Spree.config do |config|
if (ENV['DISABLE_ACTIVE_STORAGE'] == 'true')
config.image_attachment_module = 'Spree::Image::PaperclipAttachment'
config.taxon_attachment_module = 'Spree::Taxon::PaperclipAttachment'
Spree::Deprecation.silence do
config.image_attachment_module = 'Spree::Image::PaperclipAttachment'
config.taxon_attachment_module = 'Spree::Taxon::PaperclipAttachment'
end
end
end

Expand Down

0 comments on commit 6837264

Please sign in to comment.