8000 Prevent eager loading in Rails 7 · activeadmin/activeadmin@6791aa9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6791aa9

Browse files
committed
Prevent eager loading in Rails 7
Rails 7 eager loads classes in test environment when a CI is detected. This behavior was causing Zeitwerk issues when trying to eager load Active Admin files placed under `test_apps/rails_70/app/admin/`, because they are not excluded by `remove_active_admin_load_paths_from_rails_autoload_and_eager_load` This commits prevents Rails 7 to eager load classes in CI
1 parent e0de102 commit 6791aa9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

spec/support/rails_template.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@
5050

5151
copy_file File.expand_path("templates/models/tagging.rb", __dir__), "app/models/tagging.rb"
5252

53+
# Rails 7: do not eager load classes to prevent Zeitwerk errors in test_app
54+
gsub_file "config/environments/test.rb", / config.eager_load = ENV\["CI"\].present\?/, <<-RUBY
55+
config.eager_load = false
56+
RUBY
57+
5358
gsub_file "config/environments/test.rb", / config.cache_classes = true/, <<-RUBY
5459
5560
config.cache_classes = !ENV['CLASS_RELOADING']

0 commit comments

Comments
 (0)
0