diff options
author | Nick Thomas <nick@gitlab.com> | 2019-05-16 17:19:01 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-05-16 17:19:01 +0300 |
commit | 2bde9de6088cf24aae6a721c9680cf8e5814f2fc (patch) | |
tree | c8a1b75553d4cec344b465827a8bcaef197b032c /spec/controllers | |
parent | 542b2a7e356272cfdc3037b788d7e15b2f8739ac (diff) | |
parent | 9d3676846c860dcd7865b339d58588184b2f9e6c (diff) |
Merge branch 'reg-captcha-flag' into 'master'
Add :registrations_recaptcha feature flag
Closes gitlab-ee#11389
See merge request gitlab-org/gitlab-ce!28296
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/registrations_controller_spec.rb | 19 |
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..9a598790ff2 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) + 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 |