aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authoryuuji.yaginuma <yuuji.yaginuma@gmail.com>2018-12-09 15:00:01 +0900
committeryuuji.yaginuma <yuuji.yaginuma@gmail.com>2018-12-09 15:00:01 +0900
commitbad1041b82df941d588ae2565f62424d88104933 (patch)
treedba25d089c1b93213231406b256dab131d82f898 /railties/test
parent2e7e9fe1dc01c782a806f62365b69584c3cb7375 (diff)
downloadrails-bad1041b82df941d588ae2565f62424d88104933.tar.gz
rails-bad1041b82df941d588ae2565f62424d88104933.tar.bz2
rails-bad1041b82df941d588ae2565f62424d88104933.zip
Add test for reads environment credential file with environment variable key
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/credentials_test.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/railties/test/credentials_test.rb b/railties/test/credentials_test.rb
index 03370e0fc7..11765b0de5 100644
--- a/railties/test/credentials_test.rb
+++ b/railties/test/credentials_test.rb
@@ -1,9 +1,10 @@
# frozen_string_literal: true
require "isolation/abstract_unit"
+require "env_helpers"
class Rails::CredentialsTest < ActiveSupport::TestCase
- include ActiveSupport::Testing::Isolation
+ include ActiveSupport::Testing::Isolation, EnvHelpers
setup :build_app
teardown :teardown_app
@@ -38,6 +39,21 @@ class Rails::CredentialsTest < ActiveSupport::TestCase
end
end
+ test "reads credentials using environment variable key" do
+ with_credentials do |content, key|
+ Dir.chdir(app_path) do
+ Dir.mkdir("config/credentials")
+ File.write("config/credentials/production.yml.enc", content)
+ end
+
+ switch_env("RAILS_MASTER_KEY", key) do
+ app("production")
+
+ assert_equal "revealed", Rails.application.credentials.mystery
+ end
+ end
+ end
+
private
def with_credentials
key = "2117e775dc2024d4f49ddf3aeb585919"