diff options
author | Guillermo Iguaran <guilleiguaran@gmail.com> | 2016-11-21 18:56:26 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-21 18:56:26 -0500 |
commit | 6cd65861e93250159b19eac5b990a100f566e0ff (patch) | |
tree | 30fb14995a96e55732992fbe4a0bf7eaa1bb259d /railties | |
parent | 1f2e896edb05467559b1df9653d350bda1ec75cb (diff) | |
parent | 7102c6ce8984c82e0ea84b039f288f72c79dcf18 (diff) | |
download | rails-6cd65861e93250159b19eac5b990a100f566e0ff.tar.gz rails-6cd65861e93250159b19eac5b990a100f566e0ff.tar.bz2 rails-6cd65861e93250159b19eac5b990a100f566e0ff.zip |
Merge pull request #26929 from elorest/is_deep_symbolize_secrets
deep symbolize keys on secrets.yml
Diffstat (limited to 'railties')
-rw-r--r-- | railties/CHANGELOG.md | 6 | ||||
-rw-r--r-- | railties/lib/rails/application.rb | 4 | ||||
-rw-r--r-- | railties/test/application/configuration_test.rb | 14 |
3 files changed, 22 insertions, 2 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 7db7e2e34d..7e6d3acd48 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -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* diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 3b94ae4f82..f96432c89f 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -394,8 +394,8 @@ module Rails 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 diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index be84cd5027..7e3bd26212 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -636,6 +636,20 @@ module ApplicationTests 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 |