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.
This commit is contained in:
taitus
2023-06-05 19:53:15 +02:00
parent ae4cf319f6
commit 4de39918c2

View File

@@ -102,7 +102,7 @@ class Tenant < ApplicationRecord
if @cached_rails_secrets != Rails.application.secrets if @cached_rails_secrets != Rails.application.secrets
@secrets = {} @secrets = {}
@cached_rails_secrets = nil @cached_rails_secrets = Rails.application.secrets
end end
@secrets[current_schema] ||= Rails.application.secrets.merge( @secrets[current_schema] ||= Rails.application.secrets.merge(