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
2a54cbca
Commit
2a54cbca
authored
Sep 06, 2017
by
Maxim Rydkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix project_helper.rb and add couple specs to it
parent
0a08e073
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
5 deletions
+19
-5
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+5
-3
spec/helpers/projects_helper_spec.rb
spec/helpers/projects_helper_spec.rb
+14
-2
No files found.
app/helpers/projects_helper.rb
View file @
2a54cbca
...
@@ -17,11 +17,13 @@ module ProjectsHelper
...
@@ -17,11 +17,13 @@ module ProjectsHelper
def
link_to_member_avatar
(
author
,
opts
=
{})
def
link_to_member_avatar
(
author
,
opts
=
{})
default_opts
=
{
avatar:
true
,
name:
true
,
size:
16
,
author_class:
'author'
,
title:
":name"
}
default_opts
=
{
avatar:
true
,
name:
true
,
size:
16
,
author_class:
'author'
,
title:
":name"
}
opts
=
default_opts
.
merge
(
opts
)
opts
=
default_opts
.
merge
(
opts
)
classes
=
%w[avatar avatar-inline]
classes
<<
"s
#{
opts
[
:size
]
}
"
return
unless
opts
[
:avatar
]
classes
=
%W[avatar avatar-inline s
#{
opts
[
:size
]
}
]
classes
<<
opts
[
:avatar_class
]
if
opts
[
:avatar_class
]
classes
<<
opts
[
:avatar_class
]
if
opts
[
:avatar_class
]
image_tag
(
avatar_icon
(
author
,
opts
[
:size
]),
width:
opts
[
:size
],
class:
classes
,
alt:
''
)
if
opts
[
:avatar
]
image_tag
(
avatar_icon
(
author
,
opts
[
:size
]),
width:
opts
[
:size
],
class:
classes
,
alt:
''
)
end
end
def
link_to_member
(
project
,
author
,
opts
=
{},
&
block
)
def
link_to_member
(
project
,
author
,
opts
=
{},
&
block
)
...
...
spec/helpers/projects_helper_spec.rb
View file @
2a54cbca
...
@@ -193,13 +193,25 @@ describe ProjectsHelper do
...
@@ -193,13 +193,25 @@ describe ProjectsHelper do
describe
'#link_to_member_avatar'
do
describe
'#link_to_member_avatar'
do
let
(
:user
)
{
build_stubbed
(
:user
)
}
let
(
:user
)
{
build_stubbed
(
:user
)
}
let
(
:expected
)
{
double
}
it
'returns image tag for member avatar'
do
it
'returns image tag for member avatar'
do
allow
(
helper
).
to
receive
(
:image_tag
).
with
(
nil
,
{
width:
16
,
class:
[
"avatar"
,
"avatar-inline"
,
"s16"
],
alt:
""
}
)
expect
(
helper
).
to
receive
(
:avatar_icon
).
with
(
user
,
16
).
and_return
(
expected
)
allow
(
helper
).
to
receive
(
:avatar_icon
).
with
(
user
,
16
)
expect
(
helper
).
to
receive
(
:image_tag
).
with
(
expected
,
{
width:
16
,
class:
[
"avatar"
,
"avatar-inline"
,
"s16"
],
alt:
""
}
)
helper
.
link_to_member_avatar
(
user
)
helper
.
link_to_member_avatar
(
user
)
end
end
it
'returns image tag with avatar class'
do
expect
(
helper
).
to
receive
(
:avatar_icon
).
with
(
user
,
16
).
and_return
(
expected
)
expect
(
helper
).
to
receive
(
:image_tag
).
with
(
expected
,
{
width:
16
,
class:
[
"avatar"
,
"avatar-inline"
,
"s16"
,
"any-avatar-class"
],
alt:
""
})
helper
.
link_to_member_avatar
(
user
,
avatar_class:
"any-avatar-class"
)
end
it
'returns no image tag if avatar is nil'
do
expect
(
helper
.
link_to_member_avatar
(
user
,
avatar:
nil
)).
to
eq
(
nil
)
end
end
end
describe
'#link_to_member'
do
describe
'#link_to_member'
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