diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
commit | 311b0269b4eb9839fa63f80c8d7a58f32b8138a0 (patch) | |
tree | 07e7870bca8aed6d61fdcc810731c50d2c40af47 /spec/controllers/passwords_controller_spec.rb | |
parent | 27909cef6c4170ed9205afa7426b8d3de47cbb0c (diff) |
Add latest changes from gitlab-org/gitlab@14-5-stable-eev14.5.0-rc42
Diffstat (limited to 'spec/controllers/passwords_controller_spec.rb')
-rw-r--r-- | spec/controllers/passwords_controller_spec.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/controllers/passwords_controller_spec.rb b/spec/controllers/passwords_controller_spec.rb index 08d68d7cec8..01c032d9e3b 100644 --- a/spec/controllers/passwords_controller_spec.rb +++ b/spec/controllers/passwords_controller_spec.rb @@ -91,4 +91,47 @@ RSpec.describe PasswordsController do end end end + + describe '#create' do + let(:user) { create(:user) } + + subject(:perform_request) { post(:create, params: { user: { email: user.email } }) } + + context 'when reCAPTCHA is disabled' do + before do + stub_application_setting(recaptcha_enabled: false) + end + + it 'successfully sends password reset when reCAPTCHA is not solved' do + perform_request + + expect(response).to redirect_to(new_user_session_path) + expect(flash[:notice]).to include 'If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes.' + end + end + + context 'when reCAPTCHA is enabled' do + before do + stub_application_setting(recaptcha_enabled: true) + end + + it 'displays an error when the reCAPTCHA is not solved' do + Recaptcha.configuration.skip_verify_env.delete('test') + + perform_request + + expect(response).to render_template(:new) + expect(flash[:alert]).to include 'There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.' + end + + it 'successfully sends password reset when reCAPTCHA is solved' do + Recaptcha.configuration.skip_verify_env << 'test' + + perform_request + + expect(response).to redirect_to(new_user_session_path) + expect(flash[:notice]).to include 'If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes.' + end + end + end end |