mirror of https://github.com/rails/rails
Merge pull request #52679 from porras/credentials_diff_with_custom_environment
Support custom environments on bin/rails credentials:diff
This commit is contained in:
commit
9b5b8b4b32
|
@ -128,7 +128,11 @@ module Rails
|
|||
end
|
||||
|
||||
def extract_environment_from_path(path)
|
||||
available_environments.find { |env| path.end_with?("#{env}.yml.enc") }
|
||||
available_environments.find { |env| path.end_with?("#{env}.yml.enc") } || extract_custom_environment(path)
|
||||
end
|
||||
|
||||
def extract_custom_environment(path)
|
||||
path =~ %r{config/credentials/(.+)\.yml\.enc} && $1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -285,6 +285,20 @@ class Rails::Command::CredentialsTest < ActiveSupport::TestCase
|
|||
assert_match(raw_content, run_diff_command("config/credentials.yml.enc"))
|
||||
end
|
||||
|
||||
test "diff for custom environment" do
|
||||
run_edit_command(environment: "custom")
|
||||
|
||||
assert_match(/access_key_id: 123/, run_diff_command("config/credentials/custom.yml.enc"))
|
||||
end
|
||||
|
||||
test "diff for custom environment when key is not available" do
|
||||
run_edit_command(environment: "custom")
|
||||
remove_file "config/credentials/custom.key"
|
||||
|
||||
raw_content = File.read(app_path("config", "credentials", "custom.yml.enc"))
|
||||
assert_match(raw_content, run_diff_command("config/credentials/custom.yml.enc"))
|
||||
end
|
||||
|
||||
test "diff returns raw encrypted content when errors occur" do
|
||||
run_edit_command(environment: "development")
|
||||
|
||||
|
|
Loading…
Reference in New Issue