File tree Expand file tree Collapse file tree 2 files changed +8
-14
lines changed Expand file tree Collapse file tree 2 files changed +8
-14
lines changed Original file line number Diff line number Diff line change @@ -384,26 +384,14 @@ def paths
384
384
def load_database_yaml # :nodoc:
385
385
if path = paths [ "config/database" ] . existent . first
386
386
require "rails/application/dummy_config"
387
-
388
387
original_rails_config = Rails . application . config
389
- dummy_config = DummyConfig . new ( original_rails_config )
390
- database_config = { }
391
388
392
389
begin
393
- Rails . application . config = dummy_config
394
-
395
- yaml = ERB . new ( Pathname . new ( path ) . read ) . result
396
-
397
- if YAML . respond_to? ( :unsafe_load )
398
- database_config = YAML . unsafe_load ( yaml ) || { }
399
- else
400
- database_config = YAML . load ( yaml ) || { }
401
- end
390
+ Rails . application . config = DummyConfig . new ( original_rails_config )
391
+ ActiveSupport ::ConfigurationFile . parse ( Pathname . new ( path ) )
402
392
ensure
403
393
Rails . application . config = original_rails_config
404
394
end
405
-
406
- database_config
407
395
else
408
396
{ }
409
397
end
Original file line number Diff line number Diff line change @@ -2012,6 +2012,12 @@ def index
2012
2012
assert_equal ( { } , Rails . application . config . load_database_yaml )
2013
2013
end
2014
2014
2015
+ test "load_database_yaml returns blank hash if no database configuration is found" do
2016
+ remove_file "config/database.yml"
2017
+ app "development"
2018
+ assert_equal ( { } , Rails . application . config . load_database_yaml )
2019
+ end
2020
+
2015
2021
test "setup_initial_database_yaml does not print a warning if config.active_record.suppress_multiple_database_warning is true" do
2016
2022
app_file "config/database.yml" , <<-YAML
2017
2023
<%= Rails.env %>:
You can’t perform that action at this time.
0 commit comments