summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-09-06 10:54:58 -0700
committerStan Hu <stanhu@gmail.com>2019-09-06 11:38:23 -0700
commit95737ab1ce71c93b17e6728b0dcada3c1e3d14f8 (patch)
tree55353bd155424385e8481bedadb20c2cafaf9897
parent222d9e62f2f88b01542bea0890fb8fba816f83a5 (diff)
downloadgitlab-ce-sh-fix-captcha-state-pollution-spec.tar.gz
Fix order-dependent spec failures with reCAPTCHAsh-fix-captcha-state-pollution-spec
spec/controllers/registrations_controller_spec.rb polluted the test environment by changing the Recaptcha configuration. We now stub the controller's `verify_recaptcha` method instead of doing that. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/67133
-rw-r--r--spec/controllers/registrations_controller_spec.rb8
1 files changed, 1 insertions, 7 deletions
diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb
index 35487682462..e64e3a20634 100644
--- a/spec/controllers/registrations_controller_spec.rb
+++ b/spec/controllers/registrations_controller_spec.rb
@@ -74,17 +74,12 @@ describe RegistrationsController do
end
context 'when reCAPTCHA is enabled' do
- def fail_recaptcha
- # Without this, `verify_recaptcha` arbitrarily returns true in test env
- Recaptcha.configuration.skip_verify_env.delete('test')
- end
-
before do
stub_application_setting(recaptcha_enabled: true)
end
it 'displays an error when the reCAPTCHA is not solved' do
- fail_recaptcha
+ allow_any_instance_of(described_class).to receive(:verify_recaptcha).and_return(false)
post(:create, params: user_params)
@@ -105,7 +100,6 @@ describe RegistrationsController do
it 'does not require reCAPTCHA if disabled by feature flag' do
stub_feature_flags(registrations_recaptcha: false)
- fail_recaptcha
post(:create, params: user_params)