From a39aa99c8145e6782bffa1effd4f3678cab6b794 Mon Sep 17 00:00:00 2001 From: Christos Zisopoulos Date: Wed, 26 Dec 2018 00:03:20 +0100 Subject: Don't load app environment when editing credentials This avoids missing key exceptions caused by code that tries to read the credentials before they have been added to the encrypted file, for example when editing the credentials for a new environment. --- railties/test/commands/credentials_test.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'railties/test/commands') diff --git a/railties/test/commands/credentials_test.rb b/railties/test/commands/credentials_test.rb index 7842b0db61..26ffe3070c 100644 --- a/railties/test/commands/credentials_test.rb +++ b/railties/test/commands/credentials_test.rb @@ -63,6 +63,14 @@ class Rails::Command::CredentialsCommandTest < ActiveSupport::TestCase end end + test "edit command does not raise when an initializer tries to acces non-existent credentials" do + app_file "config/initializers/raise_when_loaded.rb", <<-RUBY + Rails.application.credentials.missing_key! + RUBY + + assert_match(/access_key_id: 123/, run_edit_command(environment: "qa")) + end + test "show credentials" do assert_match(/access_key_id: 123/, run_show_command) end -- cgit v1.2.3