From 4ecab980e3e2d14947562fe747908e455251797d Mon Sep 17 00:00:00 2001 From: Tim Fischbach Date: Tue, 14 Nov 2023 07:23:10 +0100 Subject: [PATCH] Skip eager loading during dummy app generation Pageflow cannot be eager loaded while it has not been configured yet. Once the initializer has been generated, we can test eager loading as part of the main test suite. REDMINE-20487 --- spec/support/pageflow/dummy/app.rb | 3 ++- spec/support/pageflow/dummy/rails_template.rb | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/spec/support/pageflow/dummy/app.rb b/spec/support/pageflow/dummy/app.rb index 5cd390c5c..b52ce1e5f 100644 --- a/spec/support/pageflow/dummy/app.rb +++ b/spec/support/pageflow/dummy/app.rb @@ -11,7 +11,8 @@ def generate if File.exist?(directory) puts("Dummy directory #{directory} exists.") else - system("bundle exec rails new #{directory} --skip-spring " \ + system('SKIP_EAGER_LOAD=true ' \ + "bundle exec rails new #{directory} --skip-spring " \ "--template #{template_path} #{rails_new_options}") || raise('Error generating dummy app.') end diff --git a/spec/support/pageflow/dummy/rails_template.rb b/spec/support/pageflow/dummy/rails_template.rb index c42d51eaa..dbf684760 100644 --- a/spec/support/pageflow/dummy/rails_template.rb +++ b/spec/support/pageflow/dummy/rails_template.rb @@ -21,6 +21,10 @@ def source_paths /^ database: /, " database: #{database_prefix}-") +gsub_file('config/environments/test.rb', + 'config.eager_load = ENV["CI"].present?', + 'config.eager_load = ENV["CI"].present? && !ENV["SKIP_EAGER_LOAD"]') + append_to_file('config/application.rb', <<-END) if ENV['PAGEFLOW_DB_HOST'].present? ActiveRecord::Tasks::DatabaseTasks::LOCAL_HOSTS << ENV['PAGEFLOW_DB_HOST']