Skip to content

Commit

Permalink
Don't hack into AM to add mail previews
Browse files Browse the repository at this point in the history
Instead just append our AM preview path let the app control wether
they're enabled or not, without forcing it only on some environments.
  • Loading branch information
elia committed Feb 26, 2021
1 parent 90d739b commit f574469
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions core/lib/spree/core/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,16 @@ class Engine < ::Rails::Engine
end
end

config.after_initialize do
ActiveSupport.on_load(:action_mailer) 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

Dir[root.join("lib/spree/mailer_previews/**/*_preview.rb")].each do |file|
require_dependency file
end
end
original_preview_path = preview_path
solidus_preview_path = Spree::Core::Engine.root.join 'lib/spree/mailer_previews/**/*_preview.rb'

self.preview_path = "{#{original_preview_path},#{solidus_preview_path}}"
end
end
end
Expand Down

0 comments on commit f574469

Please sign in to comment.