提交 1bac28d0 编写于 作者: S Stan Hu

Stub Rails.application.env_config to prevent spec failures

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
上级 e2aa2177
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册