Skip to content

Commit

Permalink
Merge pull request #3961 from nebulab/dont-check-env-for-mailer-previews
Browse files Browse the repository at this point in the history
Don't hack into ActionMailer to add our mail previews path
  • Loading branch information
kennyadsl authored Apr 30, 2021
2 parents 5cbffae + 0b30461 commit 659999c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
17 changes: 6 additions & 11 deletions core/lib/spree/core/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,13 @@ class Engine < ::Rails::Engine
end
end

config.after_initialize do
# Load in mailer previews for apps to use in development.
# We need to make sure we call `Preview.all` before requiring our
# previews, otherwise any previews the app attempts to add need to be
# manually required.
if Rails.env.development? || Rails.env.test?
ActionMailer::Preview.all
# Load in mailer previews for apps to use in development.
initializer "spree.core.action_mailer.set_preview_path", after: "action_mailer.set_configs" do |app|
original_preview_path = app.config.action_mailer.preview_path
solidus_preview_path = Spree::Core::Engine.root.join 'lib/spree/mailer_previews'

Dir[root.join("lib/spree/mailer_previews/**/*_preview.rb")].each do |file|
require_dependency file
end
end
app.config.action_mailer.preview_path = "{#{original_preview_path},#{solidus_preview_path}}"
ActionMailer::Base.preview_path = app.config.action_mailer.preview_path
end
end
end
Expand Down
1 change: 1 addition & 0 deletions core/lib/spree/testing_support/dummy_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class Application < ::Rails::Application

config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob" if RAILS_6_OR_ABOVE
config.action_mailer.preview_path = File.expand_path('dummy_app/mailer_previews', __dir__)
config.action_mailer.show_previews = true
config.active_record.sqlite3.represent_boolean_as_integer = true unless RAILS_6_OR_ABOVE

config.storage_path = Rails.root.join('tmp', 'storage')
Expand Down

0 comments on commit 659999c

Please sign in to comment.