Commit 50fea87b authored by James Fargher's avatar James Fargher

Merge branch...

Merge branch '267498-failed-test-qa-specs-features-browser_ui-1_manage-login-register_spec-rb-39-manage-standard' into 'master'

Redirect when no user is signed in when updating registration

See merge request gitlab-org/gitlab!45276
parents 9401d113 3ffc9384
...@@ -58,6 +58,8 @@ class RegistrationsController < Devise::RegistrationsController ...@@ -58,6 +58,8 @@ class RegistrationsController < Devise::RegistrationsController
end end
def update_registration def update_registration
return redirect_to new_user_registration_path unless current_user
user_params = params.require(:user).permit(:role, :setup_for_company) user_params = params.require(:user).permit(:role, :setup_for_company)
result = ::Users::SignupService.new(current_user, user_params).execute result = ::Users::SignupService.new(current_user, user_params).execute
......
---
title: Redirect when no user is signed in when updating registration
merge_request: 45276
author:
type: fixed
...@@ -59,44 +59,50 @@ RSpec.describe RegistrationsController do ...@@ -59,44 +59,50 @@ RSpec.describe RegistrationsController do
end end
describe '#update_registration' do describe '#update_registration' do
before do
sign_in(user)
end
subject(:update_registration) { patch :update_registration, params: { user: { role: 'software_developer', setup_for_company: 'false' } } } subject(:update_registration) { patch :update_registration, params: { user: { role: 'software_developer', setup_for_company: 'false' } } }
describe 'redirection' do context 'without a signed in user' do
it { is_expected.to redirect_to dashboard_projects_path } it { is_expected.to redirect_to new_user_registration_path }
end
context 'when part of the onboarding issues experiment' do context 'with a signed in user' do
before do before do
stub_experiment_for_user(onboarding_issues: true) sign_in(user)
end end
it { is_expected.to redirect_to new_users_sign_up_group_path } describe 'redirection' do
it { is_expected.to redirect_to dashboard_projects_path }
context 'when in subscription flow' do context 'when part of the onboarding issues experiment' do
before do before do
allow(controller.helpers).to receive(:in_subscription_flow?).and_return(true) stub_experiment_for_user(onboarding_issues: true)
end end
it { is_expected.not_to redirect_to new_users_sign_up_group_path } it { is_expected.to redirect_to new_users_sign_up_group_path }
end
context 'when in invitation flow' do context 'when in subscription flow' do
before do before do
allow(controller.helpers).to receive(:in_invitation_flow?).and_return(true) allow(controller.helpers).to receive(:in_subscription_flow?).and_return(true)
end
it { is_expected.not_to redirect_to new_users_sign_up_group_path }
end end
it { is_expected.not_to redirect_to new_users_sign_up_group_path } context 'when in invitation flow' do
end before do
allow(controller.helpers).to receive(:in_invitation_flow?).and_return(true)
end
context 'when in trial flow' do it { is_expected.not_to redirect_to new_users_sign_up_group_path }
before do
allow(controller.helpers).to receive(:in_trial_flow?).and_return(true)
end end
it { is_expected.not_to redirect_to new_users_sign_up_group_path } context 'when in trial flow' do
before do
allow(controller.helpers).to receive(:in_trial_flow?).and_return(true)
end
it { is_expected.not_to redirect_to new_users_sign_up_group_path }
end
end end
end end
end end
...@@ -113,6 +119,7 @@ RSpec.describe RegistrationsController do ...@@ -113,6 +119,7 @@ RSpec.describe RegistrationsController do
let(:in_trial_flow) { false } let(:in_trial_flow) { false }
before do before do
sign_in(user)
allow(::Gitlab).to receive(:com?).and_return(on_gitlab_com) allow(::Gitlab).to receive(:com?).and_return(on_gitlab_com)
stub_experiment(onboarding_issues: experiment_enabled) stub_experiment(onboarding_issues: experiment_enabled)
stub_experiment_for_user(onboarding_issues: experiment_enabled_for_user) stub_experiment_for_user(onboarding_issues: experiment_enabled_for_user)
......
...@@ -477,10 +477,16 @@ RSpec.describe RegistrationsController do ...@@ -477,10 +477,16 @@ RSpec.describe RegistrationsController do
patch :update_registration, params: { user: { role: 'software_developer', setup_for_company: 'false' } } patch :update_registration, params: { user: { role: 'software_developer', setup_for_company: 'false' } }
end end
before do context 'without a signed in user' do
sign_in(create(:user)) it { is_expected.to redirect_to new_user_registration_path }
end end
it { is_expected.to redirect_to(dashboard_projects_path)} context 'with a signed in user' do
before do
sign_in(create(:user))
end
it { is_expected.to redirect_to(dashboard_projects_path)}
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment