From 4de39918c2d0583f462afb8fdadb8e672049afa3 Mon Sep 17 00:00:00 2001 From: taitus Date: Mon, 5 Jun 2023 19:53:15 +0200 Subject: [PATCH] Fix cached secrets when running tests When running multiple specs that have to overwrite the rails secrets, it can happen that the condition: "@cached_rails_secrets != Rails.application.secrets" is not met and unexpected secrets are returned. We have found this case while experimenting with tests related to the Tenant secrets. In one case, assigning cached rails secrets to nil resulted in a failure to detect when the 'rails.application.secrets' had changed. --- app/models/tenant.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/tenant.rb b/app/models/tenant.rb index 654cbecf0..5af5af632 100644 --- a/app/models/tenant.rb +++ b/app/models/tenant.rb @@ -102,7 +102,7 @@ class Tenant < ApplicationRecord if @cached_rails_secrets != Rails.application.secrets @secrets = {} - @cached_rails_secrets = nil + @cached_rails_secrets = Rails.application.secrets end @secrets[current_schema] ||= Rails.application.secrets.merge(