diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2017-08-03 14:54:26 -0500 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2017-08-03 14:54:26 -0500 |
commit | 425aaabcfe687e507f7e2990a1213f6c4add7e6a (patch) | |
tree | bd13744d72ddc87d1ebd63f4e98e05283f8c8f15 | |
parent | da44e858ca24284dde9fcc4a6014f571290364ea (diff) | |
download | rails-425aaabcfe687e507f7e2990a1213f6c4add7e6a.tar.gz rails-425aaabcfe687e507f7e2990a1213f6c4add7e6a.tar.bz2 rails-425aaabcfe687e507f7e2990a1213f6c4add7e6a.zip |
Active Storage loads AR earlier to extend it so require env later
-rw-r--r-- | railties/test/application/initializers/frameworks_test.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/railties/test/application/initializers/frameworks_test.rb b/railties/test/application/initializers/frameworks_test.rb index eb2c578f91..add4cc23fc 100644 --- a/railties/test/application/initializers/frameworks_test.rb +++ b/railties/test/application/initializers/frameworks_test.rb @@ -233,9 +233,11 @@ module ApplicationTests test "active record establish_connection uses Rails.env if DATABASE_URL is not set" do begin - require "#{app_path}/config/environment" orig_database_url = ENV.delete("DATABASE_URL") + + require "#{app_path}/config/environment" 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]) @@ -248,11 +250,13 @@ 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]) |