diff options
Diffstat (limited to 'spec/controllers/registrations_controller_spec.rb')
-rw-r--r-- | spec/controllers/registrations_controller_spec.rb | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index caff7bcfc7b..36b230103db 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -292,13 +292,26 @@ RSpec.describe RegistrationsController do end end - it 'displays an error when the reCAPTCHA is not solved' do - allow_any_instance_of(described_class).to receive(:verify_recaptcha).and_return(false) + context 'when the reCAPTCHA is not solved' do + before do + allow_any_instance_of(described_class).to receive(:verify_recaptcha).and_return(false) + end - subject + it 'displays an error' do + subject + + expect(response).to render_template(:new) + expect(flash[:alert]).to eq(_('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.')) + end + + it 'sets gon variables' do + Gon.clear - expect(response).to render_template(:new) - expect(flash[:alert]).to eq(_('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.')) + subject + + expect(response).to render_template(:new) + expect(Gon.all_variables).not_to be_empty + end end it 'redirects to the welcome page when the reCAPTCHA is solved' do |