mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #40053 from composerinteralia/safe-yaml-config-for
Use deep_symbolize_keys instead of symbolize_names
This commit is contained in:
commit
000e2853fa
2 changed files with 14 additions and 1 deletions
|
@ -243,7 +243,7 @@ module Rails
|
|||
|
||||
if yaml.exist?
|
||||
require "erb"
|
||||
all_configs = ActiveSupport::ConfigurationFile.parse(yaml, symbolize_names: true)
|
||||
all_configs = ActiveSupport::ConfigurationFile.parse(yaml).deep_symbolize_keys
|
||||
config, shared = all_configs[env.to_sym], all_configs[:shared]
|
||||
|
||||
if config.is_a?(Hash)
|
||||
|
|
|
@ -2129,6 +2129,19 @@ module ApplicationTests
|
|||
assert_equal "unicorn", Rails.application.config.my_custom_config[:key]
|
||||
end
|
||||
|
||||
test "config_for handles YAML patches (like safe_yaml) that disable the symbolize_names option" do
|
||||
app_file "config/custom.yml", <<~RUBY
|
||||
development:
|
||||
key: value
|
||||
RUBY
|
||||
|
||||
app "development"
|
||||
|
||||
YAML.stub :load, { "development" => { "key" => "value" } } do
|
||||
assert_equal({ key: "value" }, Rails.application.config_for(:custom))
|
||||
end
|
||||
end
|
||||
|
||||
test "api_only is false by default" do
|
||||
app "development"
|
||||
assert_not Rails.application.config.api_only
|
||||
|
|
Loading…
Reference in a new issue