Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
3ffc9384
Commit
3ffc9384
authored
Oct 15, 2020
by
Alex Buijs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Require signed in user when updating registration
To prevent errors from happening
parent
28207308
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
27 deletions
+47
-27
app/controllers/registrations_controller.rb
app/controllers/registrations_controller.rb
+2
-0
changelogs/unreleased/267498-failed-test-qa-specs-features-browser_ui-1_manage-login-register_s.yml
...a-specs-features-browser_ui-1_manage-login-register_s.yml
+5
-0
ee/spec/controllers/registrations_controller_spec.rb
ee/spec/controllers/registrations_controller_spec.rb
+31
-24
spec/controllers/registrations_controller_spec.rb
spec/controllers/registrations_controller_spec.rb
+9
-3
No files found.
app/controllers/registrations_controller.rb
View file @
3ffc9384
...
...
@@ -58,6 +58,8 @@ class RegistrationsController < Devise::RegistrationsController
end
def
update_registration
return
redirect_to
new_user_registration_path
unless
current_user
user_params
=
params
.
require
(
:user
).
permit
(
:role
,
:setup_for_company
)
result
=
::
Users
::
SignupService
.
new
(
current_user
,
user_params
).
execute
...
...
changelogs/unreleased/267498-failed-test-qa-specs-features-browser_ui-1_manage-login-register_s.yml
0 → 100644
View file @
3ffc9384
---
title
:
Redirect when no user is signed in when updating registration
merge_request
:
45276
author
:
type
:
fixed
ee/spec/controllers/registrations_controller_spec.rb
View file @
3ffc9384
...
...
@@ -59,44 +59,50 @@ RSpec.describe RegistrationsController do
end
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'
}
}
}
describe
'redirection'
do
it
{
is_expected
.
to
redirect_to
dashboard_projects_path
}
context
'without a signed in user'
do
it
{
is_expected
.
to
redirect_to
new_user_registration_path
}
end
context
'when part of the onboarding issues experiment
'
do
before
do
stub_experiment_for_user
(
onboarding_issues:
true
)
end
context
'with a signed in user
'
do
before
do
sign_in
(
user
)
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
allow
(
controller
.
helpers
).
to
receive
(
:in_subscription_flow?
).
and_return
(
true
)
stub_experiment_for_user
(
onboarding_issues:
true
)
end
it
{
is_expected
.
not_to
redirect_to
new_users_sign_up_group_path
}
end
it
{
is_expected
.
to
redirect_to
new_users_sign_up_group_path
}
context
'when in invitation flow'
do
before
do
allow
(
controller
.
helpers
).
to
receive
(
:in_invitation_flow?
).
and_return
(
true
)
context
'when in subscription flow'
do
before
do
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
it
{
is_expected
.
not_to
redirect_to
new_users_sign_up_group_path
}
end
context
'when in invitation flow'
do
before
do
allow
(
controller
.
helpers
).
to
receive
(
:in_invitation_flow?
).
and_return
(
true
)
end
context
'when in trial flow'
do
before
do
allow
(
controller
.
helpers
).
to
receive
(
:in_trial_flow?
).
and_return
(
true
)
it
{
is_expected
.
not_to
redirect_to
new_users_sign_up_group_path
}
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
...
...
@@ -113,6 +119,7 @@ RSpec.describe RegistrationsController do
let
(
:in_trial_flow
)
{
false
}
before
do
sign_in
(
user
)
allow
(
::
Gitlab
).
to
receive
(
:com?
).
and_return
(
on_gitlab_com
)
stub_experiment
(
onboarding_issues:
experiment_enabled
)
stub_experiment_for_user
(
onboarding_issues:
experiment_enabled_for_user
)
...
...
spec/controllers/registrations_controller_spec.rb
View file @
3ffc9384
...
...
@@ -477,10 +477,16 @@ RSpec.describe RegistrationsController do
patch
:update_registration
,
params:
{
user:
{
role:
'software_developer'
,
setup_for_company:
'false'
}
}
end
before
do
sign_in
(
create
(
:user
))
context
'without a signed in user'
do
it
{
is_expected
.
to
redirect_to
new_user_registration_path
}
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment