Skip to content

Commit

Permalink
Fix Zeitwerk autoloading when ActionMailer is not present.
Browse files Browse the repository at this point in the history
  • Loading branch information
nashby committed Nov 17, 2024
1 parent 0f514f1 commit 7217b2d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/devise/rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
25 changes: 25 additions & 0 deletions test/zeitwerk_loader_test.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7217b2d

Please sign in to comment.