diff --git a/lib/devise/rails.rb b/lib/devise/rails.rb index dad9e86dc..b5738853f 100644 --- a/lib/devise/rails.rb +++ b/lib/devise/rails.rb @@ -47,5 +47,11 @@ class Engine < ::Rails::Engine ) end end + + initializer "devise.configure_zeitwerk" do + if Rails.autoloaders.zeitwerk_enabled? && !defined?(ActionMailer) + Rails.autoloaders.main.ignore("#{root}/app/mailers/devise/mailer.rb") + end + end end end diff --git a/test/zeitwerk_loader_test.rb b/test/zeitwerk_loader_test.rb new file mode 100644 index 000000000..a21cf63a4 --- /dev/null +++ b/test/zeitwerk_loader_test.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +ENV["RAILS_ENV"] = 'test' + +require 'rails' +require 'rails/test_help' + +require 'devise' + +class RailsTest < ActiveSupport::TestCase + test 'boot without ActionMailer' do + class MinimalApp < Rails::Application + config.root = __dir__ + config.eager_load = false + config.active_support.to_time_preserves_timezone = :zone + end + + Devise.setup do |config| + config.parent_controller = 'ActionController::Base' + end + + MinimalApp.initialize! + MinimalApp.eager_load! + end +end