diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-07 19:25:56 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-07 19:25:56 -0300 |
commit | 5ff7c591d3d5231a095afafdf2eea2fa7c70d92e (patch) | |
tree | 40b013bc179876061d78656906b1bc875da4eb8c /railties | |
parent | f274fbd240a1c4c52fe22eec181db2f429baf8da (diff) | |
parent | d14fab04ff4c32c283c7bc86c8b53b872e0fb51c (diff) | |
download | rails-5ff7c591d3d5231a095afafdf2eea2fa7c70d92e.tar.gz rails-5ff7c591d3d5231a095afafdf2eea2fa7c70d92e.tar.bz2 rails-5ff7c591d3d5231a095afafdf2eea2fa7c70d92e.zip |
Merge pull request #15015 from pothibo/database-configuration
Use Rails::Paths::Path#existent in database_configuration
Diffstat (limited to 'railties')
-rw-r--r-- | railties/CHANGELOG.md | 5 | ||||
-rw-r--r-- | railties/lib/rails/application/configuration.rb | 2 | ||||
-rw-r--r-- | railties/test/application/configuration_test.rb | 16 |
3 files changed, 22 insertions, 1 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 480ec32443..577bc86fa9 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,8 @@ +* Load database configuration from the first + database.yml available in paths. + + *Pier-Olivier Thibault* + * Reading name and email from git for plugin gemspec. Fixes #9589. diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 4c449d2c57..5e8f4de847 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -92,7 +92,7 @@ module Rails # Loads and returns the entire raw configuration of database from # values stored in `config/database.yml`. def database_configuration - yaml = Pathname.new(paths["config/database"].first || "") + yaml = Pathname.new(paths["config/database"].existent.first || "") config = if yaml.exist? require "yaml" diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 09aba1c2e9..19912805a8 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -879,5 +879,21 @@ module ApplicationTests Rails.application.load_runner assert $ran_block end + + test "loading the first existing database configuration available" do + app_file 'config/environments/development.rb', <<-RUBY + + Rails.application.configure do + config.paths.add 'config/database', with: 'config/nonexistant.yml' + config.paths['config/database'] << 'config/database.yml' + end + RUBY + + require "#{app_path}/config/environment" + + db_config = Rails.application.config.database_configuration + + assert db_config.is_a?(Hash) + end end end |