summaryrefslogtreecommitdiff
path: root/spec/controllers/registrations_controller_spec.rb
diff options
context:
space:
mode:
authorLuke Bennett <lbennett@gitlab.com>2019-05-13 17:04:09 +0100
committerLuke Bennett <lbennett@gitlab.com>2019-05-16 11:59:15 +0100
commit995a4a02a8161fa6dfb8e6a24b68b9cc57b16c45 (patch)
tree078f39c13d89abc68cc2eafa933f3add74bfc9c1 /spec/controllers/registrations_controller_spec.rb
parent3061eee6ed00708225931bab566c20d91a06a5c0 (diff)
downloadgitlab-ce-reg-captcha-flag.tar.gz
Add :registrations_recaptcha feature flagreg-captcha-flag
Allows instance owners to toggle the recaptcha requirement on the user registration page by feature flag. Allows GitLab Growth team to measure reCAPTCHA's impact on registrations.
Diffstat (limited to 'spec/controllers/registrations_controller_spec.rb')
-rw-r--r--spec/controllers/registrations_controller_spec.rb19
1 files changed, 17 insertions, 2 deletions
diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb
index 088c515c3a6..5f48ae1fec5 100644
--- a/spec/controllers/registrations_controller_spec.rb
+++ b/spec/controllers/registrations_controller_spec.rb
@@ -46,13 +46,17 @@ 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
- # Without this, `verify_recaptcha` arbitrarily returns true in test env
- Recaptcha.configuration.skip_verify_env.delete('test')
+ fail_recaptcha
post(:create, params: user_params)
@@ -70,6 +74,17 @@ describe RegistrationsController do
expect(flash[:notice]).to include 'Welcome! You have signed up successfully.'
end
+
+ it 'does not require reCAPTCHA if disabled by feature flag' do
+ stub_feature_flags(registrations_recaptcha: false)
+ fail_recaptcha
+
+ post(:create, params: user_params)
+
+ expect(controller).not_to receive(:verify_recaptcha).and_call_original
+ expect(flash[:alert]).to be_nil
+ expect(flash[:notice]).to include 'Welcome! You have signed up successfully.'
+ end
end
context 'when terms are enforced' do