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

Merge pull request #15015 from pothibo/database-configuration

Use Rails::Paths::Path#existent in database_configuration
This commit is contained in:
Rafael Mendonça França 2014-05-07 19:25:56 -03:00
commit 5ff7c591d3
3 changed files with 22 additions and 1 deletions

View file

@ -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.

View file

@ -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"

View file

@ -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