summaryrefslogtreecommitdiff
path: root/spec/controllers/confirmations_controller_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers/confirmations_controller_spec.rb')
-rw-r--r--spec/controllers/confirmations_controller_spec.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/controllers/confirmations_controller_spec.rb b/spec/controllers/confirmations_controller_spec.rb
index 401ee36b387..1c7f8de32bb 100644
--- a/spec/controllers/confirmations_controller_spec.rb
+++ b/spec/controllers/confirmations_controller_spec.rb
@@ -123,4 +123,45 @@ RSpec.describe ConfirmationsController 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(dashboard_projects_path)
+ 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(dashboard_projects_path)
+ end
+ end
+ end
end