aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/secrets_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test/secrets_test.rb')
-rw-r--r--railties/test/secrets_test.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/railties/test/secrets_test.rb b/railties/test/secrets_test.rb
index d78c253765..ff6f955a78 100644
--- a/railties/test/secrets_test.rb
+++ b/railties/test/secrets_test.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require "abstract_unit"
require "isolation/abstract_unit"
require "rails/generators"
@@ -45,7 +47,7 @@ class Rails::SecretsTest < ActiveSupport::TestCase
ENV["RAILS_MASTER_KEY"] = IO.binread("config/secrets.yml.key").strip
FileUtils.rm("config/secrets.yml.key")
- assert_match "production:\n# external_api_key", Rails::Secrets.read
+ assert_match "# production:\n# external_api_key:", Rails::Secrets.read
ensure
ENV["RAILS_MASTER_KEY"] = old_key
end
@@ -67,7 +69,7 @@ class Rails::SecretsTest < ActiveSupport::TestCase
Rails::Secrets.read_for_editing do |tmp_path|
decrypted_path = tmp_path
- assert_match(/production:\n# external_api_key/, File.read(tmp_path))
+ assert_match(/# production:\n# external_api_key/, File.read(tmp_path))
File.write(tmp_path, "Empty streets, empty nights. The Downtown Lights.")
end
@@ -133,7 +135,7 @@ class Rails::SecretsTest < ActiveSupport::TestCase
api_key: 00112233445566778899aabbccddeeff…
end_of_secrets
- Rails::Secrets.write(secrets.force_encoding(Encoding::ASCII_8BIT))
+ Rails::Secrets.write(secrets.dup.force_encoding(Encoding::ASCII_8BIT))
Rails::Secrets.read_for_editing do |tmp_path|
assert_match(/production:\n\s*api_key: 00112233445566778899aabbccddeeff…\n/, File.read(tmp_path))
@@ -153,7 +155,7 @@ class Rails::SecretsTest < ActiveSupport::TestCase
Rails::Secrets.write(secrets)
Rails::Secrets.read_for_editing do |tmp_path|
- assert_equal(secrets.force_encoding(Encoding::ASCII_8BIT), IO.binread(tmp_path))
+ assert_equal(secrets.dup.force_encoding(Encoding::ASCII_8BIT), IO.binread(tmp_path))
end
assert_equal "00112233445566778899aabbccddeeff…\n", `bin/rails runner -e production "puts Rails.application.secrets.api_key"`