aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorEugene Kenny <elkenny@gmail.com>2018-02-25 00:54:27 +0000
committerEugene Kenny <elkenny@gmail.com>2018-02-25 00:54:27 +0000
commiteb834811dc029faa059595e72294d418fb74d0a1 (patch)
tree3f4afdb6d546825aea1e853cbb08a0cb410700d2 /railties
parentefd3338b193da5ae5f0d42c4ad792d65e744428c (diff)
downloadrails-eb834811dc029faa059595e72294d418fb74d0a1.tar.gz
rails-eb834811dc029faa059595e72294d418fb74d0a1.tar.bz2
rails-eb834811dc029faa059595e72294d418fb74d0a1.zip
Use lazy load hook to configure ActiveStorage::Blob
`to_prepare` callbacks are run during initialization; using one here meant that `ActiveStorage::Blob` would be loaded when the app boots, which would in turn load `ActiveRecord::Base`. By using a lazy load hook to configure `ActiveStorage::Blob` instead, we can avoid loading `ActiveRecord::Base` unnecessarily.
Diffstat (limited to 'railties')
-rw-r--r--railties/test/application/loading_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/railties/test/application/loading_test.rb b/railties/test/application/loading_test.rb
index 2632dd7cde..889ad16fb8 100644
--- a/railties/test/application/loading_test.rb
+++ b/railties/test/application/loading_test.rb
@@ -359,6 +359,18 @@ class LoadingTest < ActiveSupport::TestCase
assert_predicate Rails.application, :initialized?
end
+ test "frameworks aren't loaded during initialization" do
+ app_file "config/initializers/raise_when_frameworks_load.rb", <<-RUBY
+ %i(action_controller action_mailer active_job active_record).each do |framework|
+ ActiveSupport.on_load(framework) { raise "\#{framework} loaded!" }
+ end
+ RUBY
+
+ assert_nothing_raised do
+ require "#{app_path}/config/environment"
+ end
+ end
+
private
def setup_ar!