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
dc09d179
Commit
dc09d179
authored
Jun 15, 2020
by
Alex Buijs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add value to onboarding_issues_settings cookie
For hiding advanced issues on the frontend
parent
d6628cd7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
0 deletions
+43
-0
app/controllers/registrations/experience_levels_controller.rb
...controllers/registrations/experience_levels_controller.rb
+11
-0
spec/controllers/registrations/experience_levels_controller_spec.rb
...ollers/registrations/experience_levels_controller_spec.rb
+32
-0
No files found.
app/controllers/registrations/experience_levels_controller.rb
View file @
dc09d179
...
@@ -13,6 +13,7 @@ module Registrations
...
@@ -13,6 +13,7 @@ module Registrations
current_user
.
experience_level
=
params
[
:experience_level
]
current_user
.
experience_level
=
params
[
:experience_level
]
if
current_user
.
save
if
current_user
.
save
hide_advanced_issues
flash
[
:message
]
=
I18n
.
t
(
'devise.registrations.signed_up'
)
flash
[
:message
]
=
I18n
.
t
(
'devise.registrations.signed_up'
)
redirect_to
group_path
(
params
[
:namespace_path
])
redirect_to
group_path
(
params
[
:namespace_path
])
else
else
...
@@ -29,5 +30,15 @@ module Registrations
...
@@ -29,5 +30,15 @@ module Registrations
def
ensure_namespace_path_param
def
ensure_namespace_path_param
redirect_to
root_path
unless
params
[
:namespace_path
].
present?
redirect_to
root_path
unless
params
[
:namespace_path
].
present?
end
end
def
hide_advanced_issues
return
unless
current_user
.
user_preference
.
novice?
settings
=
cookies
[
:onboarding_issues_settings
]
return
unless
settings
modified_settings
=
Gitlab
::
Json
.
parse
(
settings
).
merge
(
hideAdvanced:
true
)
cookies
[
:onboarding_issues_settings
]
=
modified_settings
.
to_json
end
end
end
end
end
spec/controllers/registrations/experience_levels_controller_spec.rb
View file @
dc09d179
...
@@ -97,6 +97,38 @@ describe Registrations::ExperienceLevelsController do
...
@@ -97,6 +97,38 @@ describe Registrations::ExperienceLevelsController 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
(
root_path
)
}
it
{
is_expected
.
to
redirect_to
(
root_path
)
}
end
end
describe
'applying the chosen level'
do
context
"when an 'onboarding_issues_settings' cookie does not exist"
do
let
(
:params
)
{
super
().
merge
(
experience_level: :novice
)
}
it
'does not change the cookie'
do
expect
{
subject
}.
not_to
change
{
cookies
[
:onboarding_issues_settings
]
}
end
end
context
"when an 'onboarding_issues_settings' cookie does exist"
do
before
do
request
.
cookies
[
:onboarding_issues_settings
]
=
'{}'
end
context
'when novice'
do
let
(
:params
)
{
super
().
merge
(
experience_level: :novice
)
}
it
"adds a 'hideAdvanced' setting to the cookie"
do
expect
{
subject
}.
to
change
{
Gitlab
::
Json
.
parse
(
cookies
[
:onboarding_issues_settings
])[
'hideAdvanced'
]
}.
from
(
nil
).
to
(
true
)
end
end
context
'when experienced'
do
let
(
:params
)
{
super
().
merge
(
experience_level: :experienced
)
}
it
'does not change the cookie'
do
expect
{
subject
}.
not_to
change
{
cookies
[
:onboarding_issues_settings
]
}
end
end
end
end
end
end
context
'when user update fails'
do
context
'when user update fails'
do
...
...
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