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
26264625
Commit
26264625
authored
Sep 07, 2017
by
Ruben Davila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small refactor after last code review.
parent
99dcf870
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
10 deletions
+8
-10
app/helpers/preferences_helper.rb
app/helpers/preferences_helper.rb
+1
-1
lib/gitlab/themes.rb
lib/gitlab/themes.rb
+4
-6
spec/helpers/preferences_helper_spec.rb
spec/helpers/preferences_helper_spec.rb
+3
-3
No files found.
app/helpers/preferences_helper.rb
View file @
26264625
...
@@ -41,7 +41,7 @@ module PreferencesHelper
...
@@ -41,7 +41,7 @@ module PreferencesHelper
end
end
def
user_application_theme
def
user_application_theme
Gitlab
::
Themes
.
for_user
(
current_user
).
css_class
@user_application_theme
||=
Gitlab
::
Themes
.
for_user
(
current_user
).
css_class
end
end
def
user_color_scheme
def
user_color_scheme
...
...
lib/gitlab/themes.rb
View file @
26264625
...
@@ -73,13 +73,11 @@ module Gitlab
...
@@ -73,13 +73,11 @@ module Gitlab
private
private
def
default_id
def
default_id
id
=
Gitlab
.
config
.
gitlab
.
default_theme
.
to_i
@default_id
||=
begin
id
=
Gitlab
.
config
.
gitlab
.
default_theme
.
to_i
theme_ids
=
THEMES
.
map
(
&
:id
)
# Prevent an invalid configuration setting from causing an infinite loop
theme_ids
.
include?
(
id
)
?
id
:
APPLICATION_DEFAULT
if
id
<
THEMES
.
first
.
id
||
id
>
THEMES
.
last
.
id
APPLICATION_DEFAULT
else
id
end
end
end
end
end
end
...
...
spec/helpers/preferences_helper_spec.rb
View file @
26264625
require
'spec_helper'
require
'spec_helper'
describe
PreferencesHelper
do
describe
PreferencesHelper
do
describe
'dashboard_choices'
do
describe
'
#
dashboard_choices'
do
it
'raises an exception when defined choices may be missing'
do
it
'raises an exception when defined choices may be missing'
do
expect
(
User
).
to
receive
(
:dashboards
).
and_return
(
foo:
'foo'
)
expect
(
User
).
to
receive
(
:dashboards
).
and_return
(
foo:
'foo'
)
expect
{
helper
.
dashboard_choices
}.
to
raise_error
(
RuntimeError
)
expect
{
helper
.
dashboard_choices
}.
to
raise_error
(
RuntimeError
)
...
@@ -26,7 +26,7 @@ describe PreferencesHelper do
...
@@ -26,7 +26,7 @@ describe PreferencesHelper do
end
end
end
end
describe
'user_application_theme'
do
describe
'
#
user_application_theme'
do
context
'with a user'
do
context
'with a user'
do
it
"returns user's theme's css_class"
do
it
"returns user's theme's css_class"
do
stub_user
(
theme_id:
3
)
stub_user
(
theme_id:
3
)
...
@@ -52,7 +52,7 @@ describe PreferencesHelper do
...
@@ -52,7 +52,7 @@ describe PreferencesHelper do
end
end
end
end
describe
'user_color_scheme'
do
describe
'
#
user_color_scheme'
do
context
'with a user'
do
context
'with a user'
do
it
"returns user's scheme's css_class"
do
it
"returns user's scheme's css_class"
do
allow
(
helper
).
to
receive
(
:current_user
)
allow
(
helper
).
to
receive
(
:current_user
)
...
...
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