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
05a37f69
Commit
05a37f69
authored
Aug 30, 2019
by
Jesse Hall
Committed by
Lin Jen-Shin
Aug 30, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for #56295,
https://gitlab.com/gitlab-org/gitlab-ce/issues/56295
.
All avatars now visible in commit trailers.
parent
0fa2ea2e
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
5 deletions
+75
-5
app/helpers/avatars_helper.rb
app/helpers/avatars_helper.rb
+5
-4
changelogs/unreleased/56295-some-avatars-not-visible-in-commit-trailers.yml
...sed/56295-some-avatars-not-visible-in-commit-trailers.yml
+5
-0
lib/banzai/filter/commit_trailers_filter.rb
lib/banzai/filter/commit_trailers_filter.rb
+2
-1
spec/helpers/avatars_helper_spec.rb
spec/helpers/avatars_helper_spec.rb
+42
-0
spec/lib/banzai/filter/commit_trailers_filter_spec.rb
spec/lib/banzai/filter/commit_trailers_filter_spec.rb
+21
-0
No files found.
app/helpers/avatars_helper.rb
View file @
05a37f69
...
...
@@ -56,13 +56,13 @@ module AvatarsHelper
}))
end
def
user_avatar_url_for
(
o
ptions
=
{}
)
def
user_avatar_url_for
(
o
nly_path:
true
,
**
options
)
if
options
[
:url
]
options
[
:url
]
elsif
options
[
:user
]
avatar_icon_for_user
(
options
[
:user
],
options
[
:size
])
avatar_icon_for_user
(
options
[
:user
],
options
[
:size
]
,
only_path:
only_path
)
else
avatar_icon_for_email
(
options
[
:user_email
],
options
[
:size
])
avatar_icon_for_email
(
options
[
:user_email
],
options
[
:size
]
,
only_path:
only_path
)
end
end
...
...
@@ -75,6 +75,7 @@ module AvatarsHelper
has_tooltip
=
options
[
:has_tooltip
].
nil?
?
true
:
options
[
:has_tooltip
]
data_attributes
=
options
[
:data
]
||
{}
css_class
=
%W[avatar s
#{
avatar_size
}
]
.
push
(
*
options
[
:css_class
])
alt_text
=
user_name
?
"
#{
user_name
}
's avatar"
:
"default avatar"
if
has_tooltip
css_class
.
push
(
'has-tooltip'
)
...
...
@@ -88,7 +89,7 @@ module AvatarsHelper
end
image_options
=
{
alt:
"
#{
user_name
}
's avatar"
,
alt:
alt_text
,
src:
avatar_url
,
data:
data_attributes
,
class:
css_class
,
...
...
changelogs/unreleased/56295-some-avatars-not-visible-in-commit-trailers.yml
0 → 100644
View file @
05a37f69
---
title
:
Fix for missing avatar images dislpayed in commit trailers.
merge_request
:
32374
author
:
Jesse Hall @jessehall3
type
:
fixed
lib/banzai/filter/commit_trailers_filter.rb
View file @
05a37f69
...
...
@@ -88,7 +88,8 @@ module Banzai
user:
user
,
user_email:
email
,
css_class:
'avatar-inline'
,
has_tooltip:
false
has_tooltip:
false
,
only_path:
false
)
link_href
=
user
.
nil?
?
"mailto:
#{
email
}
"
:
urls
.
user_url
(
user
)
...
...
spec/helpers/avatars_helper_spec.rb
View file @
05a37f69
...
...
@@ -324,5 +324,47 @@ describe AvatarsHelper do
)
end
end
context
'with only_path parameter set to false'
do
let
(
:user_with_avatar
)
{
create
(
:user
,
:with_avatar
,
username:
'foobar'
)
}
context
'with user parameter'
do
let
(
:options
)
{
{
user:
user_with_avatar
,
only_path:
false
}
}
it
'will return avatar with a full path'
do
is_expected
.
to
eq
tag
(
:img
,
alt:
"
#{
user_with_avatar
.
name
}
's avatar"
,
src:
avatar_icon_for_user
(
user_with_avatar
,
16
,
only_path:
false
),
data:
{
container:
'body'
},
class:
"avatar s16 has-tooltip"
,
title:
user_with_avatar
.
name
)
end
end
context
'with user_name and user_email'
do
let
(
:options
)
{
{
user_email:
user_with_avatar
.
email
,
user_name:
user_with_avatar
.
username
,
only_path:
false
}
}
it
'will return avatar with a full path'
do
is_expected
.
to
eq
tag
(
:img
,
alt:
"
#{
user_with_avatar
.
username
}
's avatar"
,
src:
avatar_icon_for_email
(
user_with_avatar
.
email
,
16
,
only_path:
false
),
data:
{
container:
'body'
},
class:
"avatar s16 has-tooltip"
,
title:
user_with_avatar
.
username
)
end
end
end
context
'with unregistered email address'
do
let
(
:options
)
{
{
user_email:
"unregistered_email@example.com"
}
}
it
'will return default alt text for avatar'
do
expect
(
subject
).
to
include
(
"default avatar"
)
end
end
end
end
spec/lib/banzai/filter/commit_trailers_filter_spec.rb
View file @
05a37f69
...
...
@@ -189,5 +189,26 @@ describe Banzai::Filter::CommitTrailersFilter do
expect_to_have_user_link_with_avatar
(
doc
,
user:
user
,
trailer:
trailer
)
expect
(
doc
.
text
).
to
include
(
commit_body
)
end
context
'with Gitlab-hosted avatars in commit trailers'
do
# Because commit trailers are contained within markdown,
# any path-only link will automatically be prefixed
# with the path of its repository.
# See: "build_relative_path" in "lib/banzai/filter/relative_link_filter.rb"
let
(
:user_with_avatar
)
{
create
(
:user
,
:with_avatar
,
username:
'foobar'
)
}
it
'returns a full path for avatar urls'
do
_
,
message_html
=
build_commit_message
(
trailer:
trailer
,
name:
user_with_avatar
.
name
,
email:
user_with_avatar
.
email
)
doc
=
filter
(
message_html
)
expected
=
"
#{
Gitlab
.
config
.
gitlab
.
url
}#{
user_with_avatar
.
avatar_url
}
"
expect
(
doc
.
css
(
'img'
)[
0
].
attr
(
'src'
)).
to
start_with
expected
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