Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-05-24 09:08:57 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-05-24 09:08:57 +0300
commitecf2b5b6048d8f289d085b5d7951381c1ef4dca0 (patch)
tree050cdc9babbc5cdc4e2a4d56ae5a68697b9dcc87 /spec
parenta67ba1bbfa161ff6e72f4d79ef5c61c7df7df947 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/confirmations_controller_spec.rb23
-rw-r--r--spec/controllers/groups_controller_spec.rb23
-rw-r--r--spec/controllers/passwords_controller_spec.rb23
-rw-r--r--spec/controllers/registrations_controller_spec.rb23
-rw-r--r--spec/controllers/sessions_controller_spec.rb25
5 files changed, 89 insertions, 28 deletions
diff --git a/spec/controllers/confirmations_controller_spec.rb b/spec/controllers/confirmations_controller_spec.rb
index 3b5afbcebca..5b137ada141 100644
--- a/spec/controllers/confirmations_controller_spec.rb
+++ b/spec/controllers/confirmations_controller_spec.rb
@@ -146,13 +146,26 @@ RSpec.describe ConfirmationsController 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')
+ context 'when the reCAPTCHA is not solved' do
+ before do
+ Recaptcha.configuration.skip_verify_env.delete('test')
+ end
- perform_request
+ it 'displays an error' do
+ 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.')
+ 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 'sets gon variables' do
+ Gon.clear
+
+ perform_request
+
+ expect(response).to render_template(:new)
+ expect(Gon.all_variables).not_to be_empty
+ end
end
it 'successfully sends password reset when reCAPTCHA is solved' do
diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb
index 4a74eff90dc..6ac00305adb 100644
--- a/spec/controllers/groups_controller_spec.rb
+++ b/spec/controllers/groups_controller_spec.rb
@@ -373,13 +373,26 @@ RSpec.describe GroupsController, factory_default: :keep do
end
end
- it 'displays an error when the reCAPTCHA is not solved' do
- allow(controller).to receive(:verify_recaptcha).and_return(false)
+ context 'when the reCAPTCHA is not solved' do
+ before do
+ allow(controller).to receive(:verify_recaptcha).and_return(false)
+ end
- post :create, params: { group: { name: 'new_group', path: "new_group" } }
+ it 'displays an error' do
+ post :create, params: { group: { name: 'new_group', path: "new_group" } }
+
+ 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
+
+ post :create, params: { group: { name: 'new_group', path: "new_group" } }
- expect(response).to render_template(:new)
- expect(flash[:alert]).to eq(_('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.'))
+ expect(response).to render_template(:new)
+ expect(Gon.all_variables).not_to be_empty
+ end
end
it 'allows creating a group when the reCAPTCHA is solved' do
diff --git a/spec/controllers/passwords_controller_spec.rb b/spec/controllers/passwords_controller_spec.rb
index 82014282c6e..e4be2fbef3c 100644
--- a/spec/controllers/passwords_controller_spec.rb
+++ b/spec/controllers/passwords_controller_spec.rb
@@ -115,13 +115,26 @@ RSpec.describe PasswordsController 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')
+ context 'when the reCAPTCHA is not solved' do
+ before do
+ Recaptcha.configuration.skip_verify_env.delete('test')
+ end
- perform_request
+ it 'displays an error' do
+ 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
- expect(response).to render_template(:new)
- expect(flash[:alert]).to include _('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.')
+ it 'sets gon variables' do
+ Gon.clear
+
+ perform_request
+
+ expect(response).to render_template(:new)
+ expect(Gon.all_variables).not_to be_empty
+ end
end
it 'successfully sends password reset when reCAPTCHA is solved' do
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
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