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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
2c69ced3
Commit
2c69ced3
authored
Jun 04, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4177 from docwhat/fix-user_color_scheme_class
user_color_scheme_class with no current_user
parents
d62bf743
336750c9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
11 deletions
+30
-11
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+8
-11
spec/helpers/application_helper_spec.rb
spec/helpers/application_helper_spec.rb
+22
-0
No files found.
app/helpers/application_helper.rb
View file @
2c69ced3
...
@@ -2,6 +2,13 @@ require 'digest/md5'
...
@@ -2,6 +2,13 @@ require 'digest/md5'
require
'uri'
require
'uri'
module
ApplicationHelper
module
ApplicationHelper
COLOR_SCHEMES
=
{
1
=>
'white'
,
2
=>
'black'
,
3
=>
'solarized-dark'
,
4
=>
'monokai'
,
}
COLOR_SCHEMES
.
default
=
'white'
# Check if a particular controller is the current one
# Check if a particular controller is the current one
#
#
...
@@ -124,17 +131,7 @@ module ApplicationHelper
...
@@ -124,17 +131,7 @@ module ApplicationHelper
end
end
def
user_color_scheme_class
def
user_color_scheme_class
# in case we dont have current_user (ex. in mailer)
COLOR_SCHEMES
[
current_user
.
try
(
:color_scheme_id
)]
return
1
unless
defined?
(
current_user
)
case
current_user
.
color_scheme_id
when
1
then
'white'
when
2
then
'black'
when
3
then
'solarized-dark'
when
4
then
'monokai'
else
'white'
end
end
end
# Define whenever show last push event
# Define whenever show last push event
...
...
spec/helpers/application_helper_spec.rb
View file @
2c69ced3
...
@@ -83,4 +83,26 @@ describe ApplicationHelper do
...
@@ -83,4 +83,26 @@ describe ApplicationHelper do
end
end
end
end
describe
"user_color_scheme_class"
do
context
"with current_user is nil"
do
it
"should return a string"
do
stub!
(
:current_user
).
and_return
(
nil
)
user_color_scheme_class
.
should
be_kind_of
(
String
)
end
end
context
"with a current_user"
do
(
1
..
5
).
each
do
|
color_scheme_id
|
context
"with color_scheme_id ==
#{
color_scheme_id
}
"
do
it
"should return a string"
do
current_user
=
double
(
:color_scheme_id
=>
color_scheme_id
)
stub!
(
:current_user
).
and_return
(
current_user
)
user_color_scheme_class
.
should
be_kind_of
(
String
)
end
end
end
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