Skip to content

Commit

Permalink
Configure Active Storage on dummy apps for extensions
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kennyadsl committed Mar 2, 2021
1 parent 1bf1dea commit 3a2d11c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/lib/generators/spree/dummy/dummy_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions core/lib/generators/spree/dummy/templates/rails/storage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test:
service: Disk
root: <%= File.expand_path("#{dummy_path}/tmp/storage", destination_root) %>
2 changes: 2 additions & 0 deletions core/lib/generators/spree/dummy/templates/rails/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3a2d11c

Please sign in to comment.