diff --git a/core/lib/spree/core/engine.rb b/core/lib/spree/core/engine.rb index 184b1a7fe8e..8cf1634c3f3 100644 --- a/core/lib/spree/core/engine.rb +++ b/core/lib/spree/core/engine.rb @@ -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