aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/credentials_test.rb
diff options
context:
space:
mode:
authorMatilda Smeds <matildasmeds@users.noreply.github.com>2018-12-09 18:28:00 +0100
committerGitHub <noreply@github.com>2018-12-09 18:28:00 +0100
commit317ad3a583fd3dbe06de8724c7fc1c6ded4cae8b (patch)
treec7084e546cbc2f289ac8cf2057c1010b4dc7f880 /railties/test/credentials_test.rb
parenta87c91cd3993d776dc987ac43b5f6c897baa3206 (diff)
parentbad1041b82df941d588ae2565f62424d88104933 (diff)
downloadrails-317ad3a583fd3dbe06de8724c7fc1c6ded4cae8b.tar.gz
rails-317ad3a583fd3dbe06de8724c7fc1c6ded4cae8b.tar.bz2
rails-317ad3a583fd3dbe06de8724c7fc1c6ded4cae8b.zip
Merge branch 'master' into guides_session_guidelines_2
Diffstat (limited to 'railties/test/credentials_test.rb')
-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"