Skip to content

Commit 7217b2d

Browse files
committed
Fix Zeitwerk autoloading when ActionMailer is not present.
1 parent 0f514f1 commit 7217b2d

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

lib/devise/rails.rb

+6
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,11 @@ class Engine < ::Rails::Engine
4747
)
4848
end
4949
end
50+
51+
initializer "devise.configure_zeitwerk" do
52+
if Rails.autoloaders.zeitwerk_enabled? && !defined?(ActionMailer)
53+
Rails.autoloaders.main.ignore("#{root}/app/mailers/devise/mailer.rb")
54+
end
55+
end
5056
end
5157
end

test/zeitwerk_loader_test.rb

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# frozen_string_literal: true
2+
3+
ENV["RAILS_ENV"] = 'test'
4+
5+
require 'rails'
6+
require 'rails/test_help'
7+
8+
require 'devise'
9+
10+
class RailsTest < ActiveSupport::TestCase
11+
test 'boot without ActionMailer' do
12+
class MinimalApp < Rails::Application
13+
config.root = __dir__
14+
config.eager_load = false
15+
config.active_support.to_time_preserves_timezone = :zone
16+
end
17+
18+
Devise.setup do |config|
19+
config.parent_controller = 'ActionController::Base'
20+
end
21+
22+
MinimalApp.initialize!
23+
MinimalApp.eager_load!
24+
end
25+
end

0 commit comments

Comments
 (0)