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,12 +59,17 @@ RSpec.describe RegistrationsController do ...@@ -59,12 +59,17 @@ RSpec.describe RegistrationsController do
end end
describe '#update_registration' do describe '#update_registration' do
subject(:update_registration) { patch :update_registration, params: { user: { role: 'software_developer', setup_for_company: 'false' } } }
context 'without a signed in user' do
it { is_expected.to redirect_to new_user_registration_path }
end
context 'with a signed in user' do
before do before do
sign_in(user) sign_in(user)
end end
subject(:update_registration) { patch :update_registration, params: { user: { role: 'software_developer', setup_for_company: 'false' } } }
describe 'redirection' do describe 'redirection' do
it { is_expected.to redirect_to dashboard_projects_path } it { is_expected.to redirect_to dashboard_projects_path }
...@@ -100,6 +105,7 @@ RSpec.describe RegistrationsController do ...@@ -100,6 +105,7 @@ RSpec.describe RegistrationsController do
end end
end end
end end
end
describe 'recording the user and tracking events for the onboarding issues experiment' do describe 'recording the user and tracking events for the onboarding issues experiment' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
...@@ -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
context 'without a signed in user' do
it { is_expected.to redirect_to new_user_registration_path }
end
context 'with a signed in user' do
before do before do
sign_in(create(:user)) sign_in(create(:user))
end end
it { is_expected.to redirect_to(dashboard_projects_path)} 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