diff --git a/app/controllers/concerns/gitlab_recaptcha.rb b/app/controllers/concerns/gitlab_recaptcha.rb index 15e856463ea..cedadba5fc7 100644 --- a/app/controllers/concerns/gitlab_recaptcha.rb +++ b/app/controllers/concerns/gitlab_recaptcha.rb @@ -17,6 +17,9 @@ module GitlabRecaptcha flash.delete :recaptcha_error self.resource = resource_class.new + + add_gon_variables + render action: 'new' end end diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index d46cf899d8c..8e395a6f446 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -360,6 +360,7 @@ class GroupsController < Groups::ApplicationController flash[:alert] = _('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.') flash.delete :recaptcha_error @group = Group.new(group_params) + add_gon_variables render action: 'new' end diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 7011bf856e3..206580d205a 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -153,6 +153,7 @@ class RegistrationsController < Devise::RegistrationsController flash[:alert] = _('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.') flash.delete :recaptcha_error + add_gon_variables render action: 'new' end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 66a531b0b3b..d9d73cb7f80 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -127,7 +127,9 @@ class SessionsController < Devise::SessionsController flash[:alert] = _('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.') flash.delete :recaptcha_error - redirect_to new_user_session_path + add_gon_variables + + respond_with_navigational(resource) { render :new } end end diff --git a/app/views/projects/_merge_request_target_project_settings.html.haml b/app/views/projects/_merge_request_target_project_settings.html.haml index 41d37884ac9..6f2917f24e0 100644 --- a/app/views/projects/_merge_request_target_project_settings.html.haml +++ b/app/views/projects/_merge_request_target_project_settings.html.haml @@ -8,16 +8,11 @@ %p.text-secondary = s_('ProjectSettings|The default target project for merge requests created in this fork project.') - .form-check.gl-mb-2 - = settings.radio_button :mr_default_target_self, false, class: "form-check-input" - = label_tag :project_project_setting_attributes_mr_default_target_self_false, class: 'form-check-label' do - .gl-font-weight-bold - = s_('ProjectSettings|Upstream project') - = @project.forked_from_project.full_name - - .form-check.gl-mb-2 - = settings.radio_button :mr_default_target_self, true, class: "form-check-input" - = label_tag :project_project_setting_attributes_mr_default_target_self_true, class: 'form-check-label' do - .gl-font-weight-bold - = s_('ProjectSettings|This project') - = @project.full_name + = settings.gitlab_ui_radio_component :mr_default_target_self, + false, + s_('ProjectSettings|Upstream project'), + help_text: @project.forked_from_project.full_name + = settings.gitlab_ui_radio_component :mr_default_target_self, + true, + s_('ProjectSettings|This project'), + help_text: @project.full_name diff --git a/qa/qa/specs/features/browser_ui/4_verify/pipeline/parent_child_pipelines_dependent_relationship_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/pipeline/parent_child_pipelines_dependent_relationship_spec.rb index f2278c7bf6d..2ceccbccc00 100644 --- a/qa/qa/specs/features/browser_ui/4_verify/pipeline/parent_child_pipelines_dependent_relationship_spec.rb +++ b/qa/qa/specs/features/browser_ui/4_verify/pipeline/parent_child_pipelines_dependent_relationship_spec.rb @@ -1,7 +1,11 @@ # frozen_string_literal: true module QA - RSpec.describe 'Verify', :runner, :reliable do + RSpec.describe 'Verify', :runner, :reliable, quarantine: { + only: { subdomain: %i[staging staging-canary] }, + issue: "https://gitlab.com/gitlab-org/gitlab/-/issues/363188", + type: :investigating + } do describe 'Parent-child pipelines dependent relationship' do let!(:project) do Resource::Project.fabricate_via_api! do |project| diff --git a/qa/qa/specs/features/browser_ui/4_verify/pipeline/parent_child_pipelines_independent_relationship_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/pipeline/parent_child_pipelines_independent_relationship_spec.rb index 9e3c29db9e7..a898c14497a 100644 --- a/qa/qa/specs/features/browser_ui/4_verify/pipeline/parent_child_pipelines_independent_relationship_spec.rb +++ b/qa/qa/specs/features/browser_ui/4_verify/pipeline/parent_child_pipelines_independent_relationship_spec.rb @@ -1,7 +1,11 @@ # frozen_string_literal: true module QA - RSpec.describe 'Verify', :runner, :reliable do + RSpec.describe 'Verify', :runner, :reliable, quarantine: { + only: { subdomain: %i[staging staging-canary] }, + issue: "https://gitlab.com/gitlab-org/gitlab/-/issues/363188", + type: :investigating + } do describe 'Parent-child pipelines independent relationship' do let!(:project) do Resource::Project.fabricate_via_api! do |project| diff --git a/qa/qa/specs/features/browser_ui/5_package/container_registry/container_registry_spec.rb b/qa/qa/specs/features/browser_ui/5_package/container_registry/container_registry_spec.rb index 27b11d697cc..3d3399a6ea1 100644 --- a/qa/qa/specs/features/browser_ui/5_package/container_registry/container_registry_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/container_registry/container_registry_spec.rb @@ -2,7 +2,11 @@ module QA RSpec.describe 'Package' do - describe 'Container Registry', :reliable, only: { subdomain: %i[staging pre] } do + describe 'Container Registry', :reliable, only: { subdomain: %i[staging pre] }, quarantine: { + only: { subdomain: %i[staging staging-canary] }, + issue: "https://gitlab.com/gitlab-org/gitlab/-/issues/363188", + type: :investigating + } do let(:project) do Resource::Project.fabricate_via_api! do |project| project.name = 'project-with-registry' @@ -37,7 +41,7 @@ module QA do docker info && break sleep 1s - done + done script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker build -t $IMAGE_TAG . diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_group_level_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_group_level_spec.rb index 921b36b34af..75967477353 100644 --- a/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_group_level_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_group_level_spec.rb @@ -1,7 +1,11 @@ # frozen_string_literal: true module QA - RSpec.describe 'Package', :orchestrated, :packages, :object_storage, :reliable do + RSpec.describe 'Package', :orchestrated, :packages, :object_storage, :reliable, quarantine: { + only: { subdomain: %i[staging staging-canary] }, + issue: "https://gitlab.com/gitlab-org/gitlab/-/issues/363188", + type: :investigating + } do describe 'Maven group level endpoint' do include Runtime::Fixtures include_context 'packages registry qa scenario' diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_project_level_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_project_level_spec.rb index 13607ba1b41..efe1a89df84 100644 --- a/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_project_level_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_project_level_spec.rb @@ -1,7 +1,11 @@ # frozen_string_literal: true module QA - RSpec.describe 'Package', :orchestrated, :packages, :object_storage, :reliable do + RSpec.describe 'Package', :orchestrated, :packages, :object_storage, :reliable, quarantine: { + only: { subdomain: %i[staging staging-canary] }, + issue: "https://gitlab.com/gitlab-org/gitlab/-/issues/363188", + type: :investigating + } do describe 'Maven project level endpoint' do let(:group_id) { 'com.gitlab.qa' } let(:artifact_id) { "maven-#{SecureRandom.hex(8)}" } diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/nuget/nuget_group_level_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/nuget/nuget_group_level_spec.rb index f229f30facc..8c0f65c447a 100644 --- a/qa/qa/specs/features/browser_ui/5_package/package_registry/nuget/nuget_group_level_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/nuget/nuget_group_level_spec.rb @@ -1,7 +1,11 @@ # frozen_string_literal: true module QA - RSpec.describe 'Package', :orchestrated, :packages, :object_storage, :reliable do + RSpec.describe 'Package', :orchestrated, :packages, :object_storage, :reliable, quarantine: { + only: { subdomain: %i[staging staging-canary] }, + issue: "https://gitlab.com/gitlab-org/gitlab/-/issues/363188", + type: :investigating + } do describe 'NuGet group level endpoint' do using RSpec::Parameterized::TableSyntax include Runtime::Fixtures 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.')) + 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(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.') + 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/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.')) + 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 + + 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