Permalink
Browse files

Merge pull request #26929 from elorest/is_deep_symbolize_secrets

deep symbolize keys on secrets.yml
  • Loading branch information...
guilleiguaran committed Nov 21, 2016
2 parents 1f2e896 + 7102c6c commit 6cd65861e93250159b19eac5b990a100f566e0ff
Showing with 22 additions and 2 deletions.
  1. +6 −0 railties/CHANGELOG.md
  2. +2 −2 railties/lib/rails/application.rb
  3. +14 −0 railties/test/application/configuration_test.rb
View
@@ -1,3 +1,9 @@
* The config file `secrets.yml` is now loaded in with all keys as symbols.
This allows secrets files to contain more complex information without all
child keys being strings while parent keys are symbols.
*Isaac Sloan*
* Add `:skip_sprockets` to `Rails::PluginBuilder::PASSTHROUGH_OPTIONS`
*Tsukuru Tanimichi*
@@ -394,8 +394,8 @@ def secrets
shared_secrets = all_secrets["shared"]
env_secrets = all_secrets[Rails.env]
secrets.merge!(shared_secrets.symbolize_keys) if shared_secrets
secrets.merge!(env_secrets.symbolize_keys) if env_secrets
secrets.merge!(shared_secrets.deep_symbolize_keys) if shared_secrets
secrets.merge!(env_secrets.deep_symbolize_keys) if env_secrets
end
# Fallback to config.secret_key_base if secrets.secret_key_base isn't set
@@ -636,6 +636,20 @@ def index
end
end
test "that nested keys are symbolized the same as parents for hashes more than one level deep" do
app_file "config/secrets.yml", <<-YAML
development:
smtp_settings:
address: "smtp.example.com"
user_name: "postmaster@example.com"
password: "697361616320736c6f616e2028656c6f7265737429"
YAML
app "development"
assert_equal "697361616320736c6f616e2028656c6f7265737429", app.secrets.smtp_settings[:password]
end
test "protect from forgery is the default in a new app" do
make_basic_app

0 comments on commit 6cd6586

Please sign in to comment.