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
Tatuya Kamada
gitlab-ce
Commits
a298f694
Commit
a298f694
authored
Jan 05, 2016
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `User#avatar_url` instead of `avatar_icon` helper
parent
7a3b7629
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
41 deletions
+20
-41
app/helpers/page_layout_helper.rb
app/helpers/page_layout_helper.rb
+4
-6
spec/helpers/page_layout_helper_spec.rb
spec/helpers/page_layout_helper_spec.rb
+16
-35
No files found.
app/helpers/page_layout_helper.rb
View file @
a298f694
...
...
@@ -49,12 +49,10 @@ module PageLayoutHelper
def
page_image
default
=
image_url
(
'gitlab_logo.png'
)
if
@project
@project
.
avatar_url
||
default
elsif
@user
avatar_icon
(
@user
)
elsif
@group
@group
.
avatar_url
||
default
subject
=
@project
||
@user
||
@group
if
subject
.
present?
subject
.
avatar_url
||
default
else
default
end
...
...
spec/helpers/page_layout_helper_spec.rb
View file @
a298f694
...
...
@@ -70,46 +70,27 @@ describe PageLayoutHelper do
expect
(
helper
.
page_image
).
to
end_with
'assets/gitlab_logo.png'
end
context
'with @project'
do
it
'uses Project avatar if available'
do
project
=
double
(
avatar_url:
'http://example.com/uploads/avatar.png'
)
assign
(
:project
,
project
)
%w(project user group)
.
each
do
|
type
|
context
"with @
#{
type
}
assigned"
do
it
"uses
#{
type
.
titlecase
}
avatar if available"
do
object
=
double
(
avatar_url:
'http://example.com/uploads/avatar.png'
)
assign
(
type
,
object
)
expect
(
helper
.
page_image
).
to
eq
project
.
avatar_url
end
it
'falls back to the default'
do
project
=
double
(
avatar_url:
nil
)
assign
(
:project
,
project
)
expect
(
helper
.
page_image
).
to
end_with
'assets/gitlab_logo.png'
end
end
context
'with @user'
do
it
'delegates to avatar_icon helper'
do
user
=
double
(
'User'
)
assign
(
:user
,
user
)
expect
(
helper
.
page_image
).
to
eq
object
.
avatar_url
end
expect
(
helper
).
to
receive
(
:avatar_icon
).
with
(
user
)
it
'falls back to the default when avatar_url is nil'
do
object
=
double
(
avatar_url:
nil
)
assign
(
type
,
object
)
helper
.
page_image
expect
(
helper
.
page_image
).
to
end_with
'assets/gitlab_logo.png'
end
end
end
context
'with @group'
do
it
'uses Group avatar if available'
do
group
=
double
(
avatar_url:
'http://example.com/uploads/avatar.png'
)
assign
(
:group
,
group
)
expect
(
helper
.
page_image
).
to
eq
group
.
avatar_url
end
it
'falls back to the default'
do
group
=
double
(
avatar_url:
nil
)
assign
(
:group
,
group
)
expect
(
helper
.
page_image
).
to
end_with
'assets/gitlab_logo.png'
context
"with no assignments"
do
it
'falls back to the default'
do
expect
(
helper
.
page_image
).
to
end_with
'assets/gitlab_logo.png'
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