mirror of https://github.com/rails/rails
do not crash when `config/secrets.yml` is blank.
This commit is contained in:
parent
8cdd93ad62
commit
37e30d2548
|
@ -1,3 +1,7 @@
|
|||
* Do not crash when `config/secrets.yml` is empty.
|
||||
|
||||
*Yves Senn*
|
||||
|
||||
* Set `dump_schema_after_migration` config values in production.
|
||||
|
||||
Set `config.active_record.dump_schema_after_migration` as false
|
||||
|
|
|
@ -308,7 +308,8 @@ module Rails
|
|||
yaml = config.paths["config/secrets"].first
|
||||
if File.exist?(yaml)
|
||||
require "erb"
|
||||
env_secrets = YAML.load(ERB.new(IO.read(yaml)).result)[Rails.env]
|
||||
all_secrets = YAML.load(ERB.new(IO.read(yaml)).result) || {}
|
||||
env_secrets = all_secrets[Rails.env]
|
||||
secrets.merge!(env_secrets.symbolize_keys) if env_secrets
|
||||
end
|
||||
|
||||
|
|
|
@ -336,6 +336,14 @@ module ApplicationTests
|
|||
assert_equal 'myamazonsecretaccesskey', app.secrets.aws_secret_access_key
|
||||
end
|
||||
|
||||
test "blank config/secrets.yml does not crash the loading process" do
|
||||
app_file 'config/secrets.yml', <<-YAML
|
||||
YAML
|
||||
require "#{app_path}/config/environment"
|
||||
|
||||
assert_nil app.secrets.not_defined
|
||||
end
|
||||
|
||||
test "protect from forgery is the default in a new app" do
|
||||
make_basic_app
|
||||
|
||||
|
|
Loading…
Reference in New Issue