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
db3bc897
Commit
db3bc897
authored
Sep 01, 2017
by
Maxim Rydkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor `app/helpers/projects_helper.rb:21:3`
parent
d441b5e7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
4 deletions
+12
-4
.rubocop.yml
.rubocop.yml
+1
-1
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+2
-2
spec/helpers/projects_helper_spec.rb
spec/helpers/projects_helper_spec.rb
+9
-1
No files found.
.rubocop.yml
View file @
db3bc897
...
...
@@ -643,7 +643,7 @@ Metrics/ClassLength:
# of test cases needed to validate a method.
Metrics/CyclomaticComplexity
:
Enabled
:
true
Max
:
1
5
Max
:
1
4
# Limit lines to 80 characters.
Metrics/LineLength
:
...
...
app/helpers/projects_helper.rb
View file @
db3bc897
...
...
@@ -17,7 +17,7 @@ module ProjectsHelper
def
link_to_member_avatar
(
author
,
opts
=
{})
default_opts
=
{
avatar:
true
,
name:
true
,
size:
16
,
author_class:
'author'
,
title:
":name"
}
opts
=
default_opts
.
merge
(
opts
)
image_tag
(
avatar_icon
(
author
,
opts
[
:size
]),
width:
opts
[
:size
],
class:
"avatar avatar-inline
#{
"s
#{
opts
[
:size
]
}
"
if
opts
[
:size
]
}
"
,
alt:
''
)
if
opts
[
:avatar
]
image_tag
(
avatar_icon
(
author
,
opts
[
:size
]),
width:
opts
[
:size
],
class:
[
'avatar'
,
'avatar-inline'
,
"
#{
"s
#{
opts
[
:size
]
}
"
if
opts
[
:size
]
}
"
,
opts
[
:avatar_class
]].
reject
(
&
:blank?
)
,
alt:
''
)
if
opts
[
:avatar
]
end
def
link_to_member
(
project
,
author
,
opts
=
{},
&
block
)
...
...
@@ -29,7 +29,7 @@ module ProjectsHelper
author_html
=
""
# Build avatar image tag
author_html
<<
image_tag
(
avatar_icon
(
author
,
opts
[
:size
]),
width:
opts
[
:size
],
class:
"avatar avatar-inline
#{
"s
#{
opts
[
:size
]
}
"
if
opts
[
:size
]
}
#{
opts
[
:avatar_class
]
if
opts
[
:avatar_class
]
}
"
,
alt:
''
)
if
opts
[
:avatar
]
author_html
<<
link_to_member_avatar
(
author
,
opts
)
if
opts
[
:avatar
]
# Build name span tag
if
opts
[
:by_username
]
...
...
spec/helpers/projects_helper_spec.rb
View file @
db3bc897
...
...
@@ -191,7 +191,15 @@ describe ProjectsHelper do
end
end
describe
'link_to_member'
do
describe
'#link_to_member_avatar'
do
let
(
:user
)
{
create
(
:user
)
}
it
'returns image tag for member avatar'
do
expect
(
helper
.
link_to_member_avatar
(
user
)).
to
eq
(
"<img width=
\"
16
\"
class=
\"
avatar avatar-inline s16 lazy
\"
alt=
\"\"
data-src=
\"
http://www.gravatar.com/avatar/a763e4acc6bc22cbabeae2638cfd4db4?s=32&d=identicon
\"
src=
\"
data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
\"
/>"
)
end
end
describe
'#link_to_member'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
group:
group
)
}
let
(
:user
)
{
create
(
: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