diff options
author | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2019-03-04 08:12:05 +0900 |
---|---|---|
committer | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2019-03-15 07:43:10 +0900 |
commit | c801b232bcb5d885e846e33e26becd33631b8c5b (patch) | |
tree | a09d66331fc1739ee7a65b66c545c98720b06503 /railties/test/commands/credentials_test.rb | |
parent | 85984e50311b7138504abe1be9bbe99f96dde8ef (diff) | |
download | rails-c801b232bcb5d885e846e33e26becd33631b8c5b.tar.gz rails-c801b232bcb5d885e846e33e26becd33631b8c5b.tar.bz2 rails-c801b232bcb5d885e846e33e26becd33631b8c5b.zip |
Properly expand the environment's name in all commands
Since 3777701f1380f3814bd5313b225586dec64d4104, the environment's name is
automatically expanded in console and dbconsole commands.
In order to match the behavior between the commands, fixes it to have the
same behavior of all the commands.
This behavior is defined in `EnvironmentArgument`. Since
`EnvironmentArgument` also defines the environment option, it is reused.
However, since desc was not content that can be used in all comments,
fixed desc to be defined for each command.
Diffstat (limited to 'railties/test/commands/credentials_test.rb')
-rw-r--r-- | railties/test/commands/credentials_test.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/railties/test/commands/credentials_test.rb b/railties/test/commands/credentials_test.rb index 10d0ba1cae..3654e96aed 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 properly expand environment option" do + assert_match(/access_key_id: 123/, run_edit_command(environment: "prod")) + Dir.chdir(app_path) do + assert File.exist?("config/credentials/production.key") + assert File.exist?("config/credentials/production.yml.enc") + end + end + test "edit command does not raise when an initializer tries to access non-existent credentials" do app_file "config/initializers/raise_when_loaded.rb", <<-RUBY Rails.application.credentials.missing_key! @@ -95,6 +103,12 @@ class Rails::Command::CredentialsCommandTest < ActiveSupport::TestCase assert_match(/access_key_id: 123/, run_show_command(environment: "production")) end + test "show command properly expand environment option" do + run_edit_command(environment: "production") + + assert_match(/access_key_id: 123/, run_show_command(environment: "prod")) + end + private def run_edit_command(editor: "cat", environment: nil, **options) switch_env("EDITOR", editor) do |