summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-11-19 22:33:45 -0800
committerStan Hu <stanhu@gmail.com>2018-11-19 23:01:24 -0800
commit1bac28d0a94b8dcc5e105b3085aa5061ec3c050b (patch)
tree77fa34bf2b253c5d25df36b07cacb0bf07780ebe
parente2aa2177a7dc66105a3ac732850f7e23f63efb82 (diff)
downloadgitlab-ce-sh-fix-issue-8448-ce.tar.gz
Stub Rails.application.env_config to prevent spec failuressh-fix-issue-8448-ce
When we modify env_config, that is on the global Rails.application, and we need to stub it and allow it to be modified in-place, without polluting later tests. When we modify env, then the context is a request, or something else that only lives for a single spec. Closes https://gitlab.com/gitlab-org/gitlab-ee/issues/8488
-rw-r--r--spec/support/helpers/devise_helpers.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/spec/support/helpers/devise_helpers.rb b/spec/support/helpers/devise_helpers.rb
index 66874e10f38..d32bc2424c0 100644
--- a/spec/support/helpers/devise_helpers.rb
+++ b/spec/support/helpers/devise_helpers.rb
@@ -8,8 +8,15 @@ module DeviseHelpers
end
def env_from_context(context)
+ # When we modify env_config, that is on the global
+ # Rails.application, and we need to stub it and allow it to be
+ # modified in-place, without polluting later tests.
if context.respond_to?(:env_config)
- context.env_config
+ context.env_config.deep_dup.tap do |env|
+ allow(context).to receive(:env_config).and_return(env)
+ end
+ # When we modify env, then the context is a request, or something
+ # else that only lives for a single spec.
elsif context.respond_to?(:env)
context.env
end