summaryrefslogtreecommitdiff
path: root/spec/controllers/sessions_controller_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-06-20 11:10:13 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-06-20 11:10:13 +0000
commit0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch)
tree7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /spec/controllers/sessions_controller_spec.rb
parent72123183a20411a36d607d70b12d57c484394c8e (diff)
downloadgitlab-ce-0ea3fcec397b69815975647f5e2aa5fe944a8486.tar.gz
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'spec/controllers/sessions_controller_spec.rb')
-rw-r--r--spec/controllers/sessions_controller_spec.rb25
1 files changed, 17 insertions, 8 deletions
diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb
index 877ca7cd6c6..0e0770fb94c 100644
--- a/spec/controllers/sessions_controller_spec.rb
+++ b/spec/controllers/sessions_controller_spec.rb
@@ -233,14 +233,23 @@ RSpec.describe SessionsController do
request.headers[described_class::CAPTCHA_HEADER] = '1'
end
- it 'displays an error when the reCAPTCHA is not solved' do
- # Without this, `verify_recaptcha` arbitrarily returns true in test env
+ context 'when the reCAPTCHA is not solved' do
+ it 'displays an error' do
+ unsuccesful_login(user_params)
- unsuccesful_login(user_params)
+ expect(response).to render_template(:new)
+ expect(flash[:alert]).to include _('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.')
+ expect(subject.current_user).to be_nil
+ end
- expect(response).to redirect_to new_user_session_path
- expect(flash[:alert]).to include _('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.')
- expect(subject.current_user).to be_nil
+ it 'sets gon variables' do
+ Gon.clear
+
+ unsuccesful_login(user_params)
+
+ expect(response).to render_template(:new)
+ expect(Gon.all_variables).not_to be_empty
+ end
end
it 'successfully logs in a user when reCAPTCHA is solved' do
@@ -262,7 +271,7 @@ RSpec.describe SessionsController do
it 'displays an error when the reCAPTCHA is not solved' do
unsuccesful_login(user_params, sesion_params: { failed_login_attempts: 6 })
- expect(response).to redirect_to new_user_session_path
+ expect(response).to render_template(:new)
expect(flash[:alert]).to include _('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.')
expect(subject.current_user).to be_nil
end
@@ -282,7 +291,7 @@ RSpec.describe SessionsController do
it 'displays an error when the reCAPTCHA is not solved' do
unsuccesful_login(user_params)
- expect(response).to redirect_to new_user_session_path
+ expect(response).to render_template(:new)
expect(flash[:alert]).to include _('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.')
expect(subject.current_user).to be_nil
end