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
95f2bd92
Commit
95f2bd92
authored
Jun 09, 2020
by
Dallas Reedy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure we always have a namespace_path param
parent
f9f3f399
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
13 deletions
+17
-13
app/controllers/registrations/experience_levels_controller.rb
...controllers/registrations/experience_levels_controller.rb
+6
-1
ee/app/controllers/registrations/projects_controller.rb
ee/app/controllers/registrations/projects_controller.rb
+1
-1
spec/controllers/registrations/experience_levels_controller_spec.rb
...ollers/registrations/experience_levels_controller_spec.rb
+10
-11
No files found.
app/controllers/registrations/experience_levels_controller.rb
View file @
95f2bd92
...
@@ -7,13 +7,14 @@ module Registrations
...
@@ -7,13 +7,14 @@ module Registrations
layout
'devise_experimental_separate_sign_up_flow'
layout
'devise_experimental_separate_sign_up_flow'
before_action
:check_experiment_enabled
before_action
:check_experiment_enabled
before_action
:ensure_namespace_path_param
def
update
def
update
current_user
.
experience_level
=
params
[
:experience_level
]
current_user
.
experience_level
=
params
[
:experience_level
]
if
current_user
.
save
if
current_user
.
save
flash
[
:message
]
=
I18n
.
t
(
'devise.registrations.signed_up'
)
flash
[
:message
]
=
I18n
.
t
(
'devise.registrations.signed_up'
)
redirect_to
group_path
(
params
[
:namespace_path
]
||
current_user
)
redirect_to
group_path
(
params
[
:namespace_path
])
else
else
render
:show
render
:show
end
end
...
@@ -24,5 +25,9 @@ module Registrations
...
@@ -24,5 +25,9 @@ module Registrations
def
check_experiment_enabled
def
check_experiment_enabled
access_denied!
unless
experiment_enabled?
(
:onboarding_issues
)
access_denied!
unless
experiment_enabled?
(
:onboarding_issues
)
end
end
def
ensure_namespace_path_param
redirect_to
root_path
unless
params
[
:namespace_path
].
present?
end
end
end
end
end
ee/app/controllers/registrations/projects_controller.rb
View file @
95f2bd92
...
@@ -16,7 +16,7 @@ module Registrations
...
@@ -16,7 +16,7 @@ module Registrations
if
@project
.
saved?
if
@project
.
saved?
create_learn_gitlab_project
create_learn_gitlab_project
redirect_to
users_sign_up_experience_level_path
(
namespace_path:
@project
.
namespace
.
to_param
)
redirect_to
users_sign_up_experience_level_path
(
namespace_path:
@project
.
namespace
)
else
else
render
:new
render
:new
end
end
...
...
spec/controllers/registrations/experience_levels_controller_spec.rb
View file @
95f2bd92
...
@@ -3,10 +3,13 @@
...
@@ -3,10 +3,13 @@
require
'spec_helper'
require
'spec_helper'
describe
Registrations
::
ExperienceLevelsController
do
describe
Registrations
::
ExperienceLevelsController
do
let_it_be
(
:namespace
)
{
create
(
:group
,
path:
'group-path'
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let
(
:params
)
{
{
namespace_path:
namespace
.
to_param
}
}
describe
'GET #show'
do
describe
'GET #show'
do
subject
{
get
:show
}
subject
{
get
:show
,
params:
params
}
context
'with an unauthenticated user'
do
context
'with an unauthenticated user'
do
it
{
is_expected
.
to
have_gitlab_http_status
(
:redirect
)
}
it
{
is_expected
.
to
have_gitlab_http_status
(
:redirect
)
}
...
@@ -35,10 +38,6 @@ describe Registrations::ExperienceLevelsController do
...
@@ -35,10 +38,6 @@ describe Registrations::ExperienceLevelsController do
describe
'PUT/PATCH #update'
do
describe
'PUT/PATCH #update'
do
subject
{
patch
:update
,
params:
params
}
subject
{
patch
:update
,
params:
params
}
let_it_be
(
:namespace
)
{
create
(
:group
,
path:
'group-path'
)
}
let
(
:params
)
{
{}
}
context
'with an unauthenticated user'
do
context
'with an unauthenticated user'
do
it
{
is_expected
.
to
have_gitlab_http_status
(
:redirect
)
}
it
{
is_expected
.
to
have_gitlab_http_status
(
:redirect
)
}
it
{
is_expected
.
to
redirect_to
(
new_user_session_path
)
}
it
{
is_expected
.
to
redirect_to
(
new_user_session_path
)
}
...
@@ -72,15 +71,15 @@ describe Registrations::ExperienceLevelsController do
...
@@ -72,15 +71,15 @@ describe Registrations::ExperienceLevelsController do
end
end
context
'when an expected experience level is sent'
do
context
'when an expected experience level is sent'
do
let
(
:params
)
{
{
experience_level: :novice
}
}
let
(
:params
)
{
super
().
merge
(
experience_level: :novice
)
}
it
'sets the user’s experience level'
do
it
'sets the user’s experience level'
do
expect
{
subject
}.
to
change
{
user
.
reload
.
experience_level
}.
to
(
'novice'
)
expect
{
subject
}.
to
change
{
user
.
reload
.
experience_level
}.
from
(
nil
).
to
(
'novice'
)
end
end
end
end
context
'when an unexpected experience level is sent'
do
context
'when an unexpected experience level is sent'
do
let
(
:params
)
{
{
experience_level: :nonexistent
}
}
let
(
:params
)
{
super
().
merge
(
experience_level: :nonexistent
)
}
it
'raises an exception'
do
it
'raises an exception'
do
expect
{
subject
}.
to
raise_error
(
ArgumentError
,
"'nonexistent' is not a valid experience_level"
)
expect
{
subject
}.
to
raise_error
(
ArgumentError
,
"'nonexistent' is not a valid experience_level"
)
...
@@ -88,15 +87,15 @@ describe Registrations::ExperienceLevelsController do
...
@@ -88,15 +87,15 @@ describe Registrations::ExperienceLevelsController do
end
end
context
'when a namespace_path is sent'
do
context
'when a namespace_path is sent'
do
let
(
:params
)
{
{
namespace_path:
namespace
.
to_param
}
}
it
{
is_expected
.
to
have_gitlab_http_status
(
:redirect
)
}
it
{
is_expected
.
to
have_gitlab_http_status
(
:redirect
)
}
it
{
is_expected
.
to
redirect_to
(
group_path
(
namespace
))
}
it
{
is_expected
.
to
redirect_to
(
group_path
(
namespace
))
}
end
end
context
'when no namespace_path is sent'
do
context
'when no namespace_path is sent'
do
let
(
:params
)
{
super
().
merge
(
namespace_path:
nil
)
}
it
{
is_expected
.
to
have_gitlab_http_status
(
:redirect
)
}
it
{
is_expected
.
to
have_gitlab_http_status
(
:redirect
)
}
it
{
is_expected
.
to
redirect_to
(
user_path
(
user
)
)
}
it
{
is_expected
.
to
redirect_to
(
root_path
)
}
end
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