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
Boxiang Sun
gitlab-ce
Commits
d94df6ef
Commit
d94df6ef
authored
Sep 25, 2017
by
kushalpandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update tests to reflect `user_avatar_without_link` helper changes
parent
abb9981d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
40 deletions
+62
-40
spec/helpers/avatars_helper_spec.rb
spec/helpers/avatars_helper_spec.rb
+62
-40
No files found.
spec/helpers/avatars_helper_spec.rb
View file @
d94df6ef
...
@@ -26,12 +26,13 @@ describe AvatarsHelper do
...
@@ -26,12 +26,13 @@ describe AvatarsHelper do
subject
{
helper
.
user_avatar_without_link
(
options
)
}
subject
{
helper
.
user_avatar_without_link
(
options
)
}
it
'displays user avatar'
do
it
'displays user avatar'
do
is_expected
.
to
eq
image_tag
(
is_expected
.
to
eq
tag
(
LazyImageTagHelper
.
placeholder_image
,
:img
,
class:
'avatar s16 has-tooltip lazy'
,
alt:
"
#{
user
.
name
}
's avatar"
,
alt:
"
#{
user
.
name
}
's avatar"
,
title:
user
.
name
,
src:
avatar_icon
(
user
,
16
),
data:
{
container:
'body'
,
src:
avatar_icon
(
user
,
16
)
}
data:
{
container:
'body'
},
class:
'avatar s16 has-tooltip'
,
title:
user
.
name
)
)
end
end
...
@@ -39,12 +40,13 @@ describe AvatarsHelper do
...
@@ -39,12 +40,13 @@ describe AvatarsHelper do
let
(
:options
)
{
{
user:
user
,
css_class:
'.cat-pics'
}
}
let
(
:options
)
{
{
user:
user
,
css_class:
'.cat-pics'
}
}
it
'uses provided css_class'
do
it
'uses provided css_class'
do
is_expected
.
to
eq
image_tag
(
is_expected
.
to
eq
tag
(
LazyImageTagHelper
.
placeholder_image
,
:img
,
class:
"avatar s16
#{
options
[
:css_class
]
}
has-tooltip lazy"
,
alt:
"
#{
user
.
name
}
's avatar"
,
alt:
"
#{
user
.
name
}
's avatar"
,
title:
user
.
name
,
src:
avatar_icon
(
user
,
16
),
data:
{
container:
'body'
,
src:
avatar_icon
(
user
,
16
)
}
data:
{
container:
'body'
},
class:
"avatar s16
#{
options
[
:css_class
]
}
has-tooltip"
,
title:
user
.
name
)
)
end
end
end
end
...
@@ -53,12 +55,13 @@ describe AvatarsHelper do
...
@@ -53,12 +55,13 @@ describe AvatarsHelper do
let
(
:options
)
{
{
user:
user
,
size:
99
}
}
let
(
:options
)
{
{
user:
user
,
size:
99
}
}
it
'uses provided size'
do
it
'uses provided size'
do
is_expected
.
to
eq
image_tag
(
is_expected
.
to
eq
tag
(
LazyImageTagHelper
.
placeholder_image
,
:img
,
class:
"avatar s
#{
options
[
:size
]
}
has-tooltip lazy"
,
alt:
"
#{
user
.
name
}
's avatar"
,
alt:
"
#{
user
.
name
}
's avatar"
,
title:
user
.
name
,
src:
avatar_icon
(
user
,
options
[
:size
]),
data:
{
container:
'body'
,
src:
avatar_icon
(
user
,
options
[
:size
])
}
data:
{
container:
'body'
},
class:
"avatar s
#{
options
[
:size
]
}
has-tooltip"
,
title:
user
.
name
)
)
end
end
end
end
...
@@ -67,12 +70,28 @@ describe AvatarsHelper do
...
@@ -67,12 +70,28 @@ describe AvatarsHelper do
let
(
:options
)
{
{
user:
user
,
url:
'/over/the/rainbow.png'
}
}
let
(
:options
)
{
{
user:
user
,
url:
'/over/the/rainbow.png'
}
}
it
'uses provided url'
do
it
'uses provided url'
do
is_expected
.
to
eq
image_tag
(
is_expected
.
to
eq
tag
(
LazyImageTagHelper
.
placeholder_image
,
:img
,
class:
'avatar s16 has-tooltip lazy'
,
alt:
"
#{
user
.
name
}
's avatar"
,
alt:
"
#{
user
.
name
}
's avatar"
,
title:
user
.
name
,
src:
options
[
:url
],
data:
{
container:
'body'
,
src:
options
[
:url
]
}
data:
{
container:
'body'
},
class:
"avatar s16 has-tooltip"
,
title:
user
.
name
)
end
end
context
'with lazy parameter'
do
let
(
:options
)
{
{
user:
user
,
lazy:
true
}
}
it
'adds `lazy` class to class list, sets `data-src` with avatar URL and `src` with placeholder image'
do
is_expected
.
to
eq
tag
(
:img
,
alt:
"
#{
user
.
name
}
's avatar"
,
src:
LazyImageTagHelper
.
placeholder_image
,
data:
{
container:
'body'
,
src:
avatar_icon
(
user
,
16
)
},
class:
"avatar s16 has-tooltip lazy"
,
title:
user
.
name
)
)
end
end
end
end
...
@@ -82,12 +101,13 @@ describe AvatarsHelper do
...
@@ -82,12 +101,13 @@ describe AvatarsHelper do
let
(
:options
)
{
{
user:
user
,
has_tooltip:
true
}
}
let
(
:options
)
{
{
user:
user
,
has_tooltip:
true
}
}
it
'adds has-tooltip'
do
it
'adds has-tooltip'
do
is_expected
.
to
eq
image_tag
(
is_expected
.
to
eq
tag
(
LazyImageTagHelper
.
placeholder_image
,
:img
,
class:
'avatar s16 has-tooltip lazy'
,
alt:
"
#{
user
.
name
}
's avatar"
,
alt:
"
#{
user
.
name
}
's avatar"
,
title:
user
.
name
,
src:
avatar_icon
(
user
,
16
),
data:
{
container:
'body'
,
src:
avatar_icon
(
user
,
16
)
}
data:
{
container:
'body'
},
class:
"avatar s16 has-tooltip"
,
title:
user
.
name
)
)
end
end
end
end
...
@@ -96,12 +116,12 @@ describe AvatarsHelper do
...
@@ -96,12 +116,12 @@ describe AvatarsHelper do
let
(
:options
)
{
{
user:
user
,
has_tooltip:
false
}
}
let
(
:options
)
{
{
user:
user
,
has_tooltip:
false
}
}
it
'does not add has-tooltip or data container'
do
it
'does not add has-tooltip or data container'
do
is_expected
.
to
eq
image_tag
(
is_expected
.
to
eq
tag
(
LazyImageTagHelper
.
placeholder_image
,
:img
,
class:
'avatar s16 lazy'
,
alt:
"
#{
user
.
name
}
's avatar"
,
alt:
"
#{
user
.
name
}
's avatar"
,
title:
user
.
name
,
src:
avatar_icon
(
user
,
16
),
data:
{
src:
avatar_icon
(
user
,
16
)
}
class:
"avatar s16"
,
title:
user
.
name
)
)
end
end
end
end
...
@@ -114,23 +134,25 @@ describe AvatarsHelper do
...
@@ -114,23 +134,25 @@ describe AvatarsHelper do
let
(
:options
)
{
{
user:
user
,
user_name:
'Tinky Winky'
}
}
let
(
:options
)
{
{
user:
user
,
user_name:
'Tinky Winky'
}
}
it
'prefers user parameter'
do
it
'prefers user parameter'
do
is_expected
.
to
eq
image_tag
(
is_expected
.
to
eq
tag
(
LazyImageTagHelper
.
placeholder_image
,
:img
,
class:
'avatar s16 has-tooltip lazy'
,
alt:
"
#{
user
.
name
}
's avatar"
,
alt:
"
#{
user
.
name
}
's avatar"
,
title:
user
.
name
,
src:
avatar_icon
(
user
,
16
),
data:
{
container:
'body'
,
src:
avatar_icon
(
user
,
16
)
}
data:
{
container:
'body'
},
class:
"avatar s16 has-tooltip"
,
title:
user
.
name
)
)
end
end
end
end
it
'uses user_name and user_email parameter if user is not present'
do
it
'uses user_name and user_email parameter if user is not present'
do
is_expected
.
to
eq
image_tag
(
is_expected
.
to
eq
tag
(
LazyImageTagHelper
.
placeholder_image
,
:img
,
class:
'avatar s16 has-tooltip lazy'
,
alt:
"
#{
options
[
:user_name
]
}
's avatar"
,
alt:
"
#{
options
[
:user_name
]
}
's avatar"
,
title:
options
[
:user_name
],
src:
avatar_icon
(
options
[
:user_email
],
16
),
data:
{
container:
'body'
,
src:
avatar_icon
(
options
[
:user_email
],
16
)
}
data:
{
container:
'body'
},
class:
"avatar s16 has-tooltip"
,
title:
options
[
:user_name
]
)
)
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