From fffd555faef98e146ad1bc7a345de9c51c705611 Mon Sep 17 00:00:00 2001 From: Alberto Vena Date: Tue, 2 Mar 2021 08:51:38 +0100 Subject: [PATCH 1/2] Use Active Storage adapters as default configuration value This is important because extensions that are testing against Solidus 3.0 does not have the default adapter set to Active Storage; extensions' dummy app is not executing the solidus:install command and won't have the intializer copied over to configure the app. --- core/lib/spree/app_configuration.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/lib/spree/app_configuration.rb b/core/lib/spree/app_configuration.rb index f058d12d39c..127c02ef83f 100644 --- a/core/lib/spree/app_configuration.rb +++ b/core/lib/spree/app_configuration.rb @@ -437,23 +437,23 @@ def payment_canceller # Allows switching attachment library for Image # - # `Spree::Image::PaperclipAttachment` - # is the default and provides the classic Paperclip implementation. + # `Spree::Image::ActiveStorageAttachment` + # is the default and provides the Active Storage implementation. # # @!attribute [rw] image_attachment_module # @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::PaperclipAttachment' + class_name_attribute :image_attachment_module, default: 'Spree::Image::ActiveStorageAttachment' # Allows switching attachment library for Taxon # - # `Spree::Taxon::PaperclipAttachment` - # is the default and provides the classic Paperclip implementation. + # `Spree::Taxon::ActiveStorageAttachment` + # is the default and provides the Active Storage implementation. # # @!attribute [rw] taxon_attachment_module # @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::PaperclipAttachment' + class_name_attribute :taxon_attachment_module, default: 'Spree::Taxon::ActiveStorageAttachment' # Allows providing your own class instance for generating order numbers. # From db7ff8d02057c1abe6a78a836b4968e340e3041d Mon Sep 17 00:00:00 2001 From: Alberto Vena Date: Tue, 2 Mar 2021 10:23:28 +0100 Subject: [PATCH 2/2] Configure Active Storage on dummy apps for extensions Copying the .yml configuration file into config/storage/test.yml will automatically configure Active Storage in that env [1]. The configuration key needs to be the same of the service set into config/environments/test.rb. When testing extensions against old versions of Solidus, it will not use Active Storage so, it should not be harmful to have it configured anyway. [1]: https://github.com/rails/rails/blob/66b861f24cd8ca34b726f77b46f6b25b21f0b972/activestorage/lib/active_storage/engine.rb#L115-L132 --- core/lib/generators/spree/dummy/dummy_generator.rb | 1 + core/lib/generators/spree/dummy/templates/rails/storage.yml | 3 +++ core/lib/generators/spree/dummy/templates/rails/test.rb | 2 ++ 3 files changed, 6 insertions(+) create mode 100644 core/lib/generators/spree/dummy/templates/rails/storage.yml diff --git a/core/lib/generators/spree/dummy/dummy_generator.rb b/core/lib/generators/spree/dummy/dummy_generator.rb index 09582e599bd..2292761e5d1 100644 --- a/core/lib/generators/spree/dummy/dummy_generator.rb +++ b/core/lib/generators/spree/dummy/dummy_generator.rb @@ -55,6 +55,7 @@ def test_dummy_config @database = options[:database] template "rails/database.yml", "#{dummy_path}/config/database.yml", force: true + template "rails/storage.yml", "#{dummy_path}/config/storage/test.yml", force: true template "rails/boot.rb", "#{dummy_path}/config/boot.rb", force: true template "rails/application.rb.tt", "#{dummy_path}/config/application.rb", force: true template "rails/routes.rb", "#{dummy_path}/config/routes.rb", force: true diff --git a/core/lib/generators/spree/dummy/templates/rails/storage.yml b/core/lib/generators/spree/dummy/templates/rails/storage.yml new file mode 100644 index 00000000000..9f2a8d8c360 --- /dev/null +++ b/core/lib/generators/spree/dummy/templates/rails/storage.yml @@ -0,0 +1,3 @@ +test: + service: Disk + root: <%= File.expand_path("#{dummy_path}/tmp/storage", destination_root) %> diff --git a/core/lib/generators/spree/dummy/templates/rails/test.rb b/core/lib/generators/spree/dummy/templates/rails/test.rb index 6c029ce51cc..0a2d9aabe8f 100644 --- a/core/lib/generators/spree/dummy/templates/rails/test.rb +++ b/core/lib/generators/spree/dummy/templates/rails/test.rb @@ -29,6 +29,8 @@ config.action_mailer.delivery_method = :test ActionMailer::Base.default from: "solidus@example.com" + config.active_storage.service = :test + # Raise on deprecation warnings if ENV['SOLIDUS_RAISE_DEPRECATIONS'].present? Spree::Deprecation.behavior = :raise