1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Do not eager load ActiveRecord::Base

Everything inside the app directory of a engine is autoload/eager loaded automatically so we don't need to require them.
This commit is contained in:
Rafael Mendonça França 2017-08-03 16:40:37 -04:00
parent 6a36b6b0cc
commit f601a01b2c
6 changed files with 6 additions and 22 deletions

View file

@ -1,5 +1,3 @@
require "active_storage/variant"
# Take a signed permanent reference for a variant and turn it into an expiring service URL for download.
# Note: These URLs are publicly accessible. If you need to enforce access protection beyond the
# security-through-obscurity factor of the signed blob and variation reference, you'll need to implement your own

View file

@ -1,4 +1,3 @@
require "active_storage/blob"
require "active_support/core_ext/module/delegation"
# Attachments associate records with blobs. Usually that's a one record-many blobs relationship,

View file

@ -1,9 +1,3 @@
require "active_storage/service"
require "active_storage/filename"
require "active_storage/purge_job"
require "active_storage/variant"
require "active_storage/variation"
# A blob is a record that contains the metadata about a file and a key for where that file resides on the service.
# Blobs can be created in two ways:
#

View file

@ -1,6 +1,3 @@
require "active_storage/blob"
require "active_storage/attachment"
require "action_dispatch/http/upload"
require "active_support/core_ext/module/delegation"

View file

@ -233,11 +233,9 @@ module ApplicationTests
test "active record establish_connection uses Rails.env if DATABASE_URL is not set" do
begin
orig_database_url = ENV.delete("DATABASE_URL")
require "#{app_path}/config/environment"
orig_database_url = ENV.delete("DATABASE_URL")
orig_rails_env, Rails.env = Rails.env, "development"
ActiveRecord::Base.establish_connection
assert ActiveRecord::Base.connection
assert_match(/#{ActiveRecord::Base.configurations[Rails.env]['database']}/, ActiveRecord::Base.connection_config[:database])
@ -250,13 +248,11 @@ module ApplicationTests
test "active record establish_connection uses DATABASE_URL even if Rails.env is set" do
begin
require "#{app_path}/config/environment"
orig_database_url = ENV.delete("DATABASE_URL")
orig_rails_env, Rails.env = Rails.env, "development"
database_url_db_name = "db/database_url_db.sqlite3"
ENV["DATABASE_URL"] = "sqlite3:#{database_url_db_name}"
require "#{app_path}/config/environment"
orig_rails_env, Rails.env = Rails.env, "development"
ActiveRecord::Base.establish_connection
assert ActiveRecord::Base.connection
assert_match(/#{database_url_db_name}/, ActiveRecord::Base.connection_config[:database])

View file

@ -42,8 +42,8 @@ module ApplicationTests
end
test "db:create and db:drop with database url" do
set_database_url
require "#{app_path}/config/environment"
set_database_url
db_create_and_drop database_url_db_name
end
@ -154,8 +154,8 @@ module ApplicationTests
end
test "db:fixtures:load with database_url" do
set_database_url
require "#{app_path}/config/environment"
set_database_url
db_fixtures_load database_url_db_name
end
@ -189,8 +189,8 @@ module ApplicationTests
end
test "db:structure:dump and db:structure:load with database_url" do
set_database_url
require "#{app_path}/config/environment"
set_database_url
db_structure_dump_and_load database_url_db_name
end