diff options
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/application/configuration.rb | 13 | ||||
-rw-r--r-- | railties/test/application/rake/dbs_test.rb | 13 |
2 files changed, 7 insertions, 19 deletions
diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 17763b39c5..8abd2dc572 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -98,14 +98,15 @@ module Rails end # Loads and returns the configuration of the database. - # First, looks at If ENV['DATABASE_URL'] if it's not present it uses the #paths["config/database"] - # The contents of the file are processed via ERB before being sent through YAML::load. def database_configuration - if ENV['DATABASE_URL'] - {Rails.env => ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver.connection_url_to_hash(ENV['DATABASE_URL']).stringify_keys} + yaml = paths["config/database"].first + if File.exists?(yaml) + require "erb" + YAML.load ERB.new(IO.read(yaml)).result + elsif ENV['DATABASE_URL'] + nil else - require 'erb' - YAML.load ERB.new(IO.read(paths["config/database"].first)).result + raise "Could not load database configuration. No such file - #{yaml}" end rescue Psych::SyntaxError => e raise "YAML syntax error occurred while parsing #{paths["config/database"].first}. " \ diff --git a/railties/test/application/rake/dbs_test.rb b/railties/test/application/rake/dbs_test.rb index 820b838702..9e711f25bd 100644 --- a/railties/test/application/rake/dbs_test.rb +++ b/railties/test/application/rake/dbs_test.rb @@ -166,19 +166,6 @@ module ApplicationTests require "#{app_path}/config/environment" db_test_load_structure end - - test 'db:test:load_structure with database_url' do - old_rails_env = ENV["RAILS_ENV"] - ENV["RAILS_ENV"] = 'test' - - begin - require "#{app_path}/config/environment" - set_database_url - db_test_load_structure - ensure - ENV["RAILS_ENV"] = old_rails_env - end - end end end end |