Commit 85e6ffb5 authored by Fatih Acet's avatar Fatih Acet

Merge branch 'nogravatar-fix-default-avatar' into 'master'

Fix avatar icon missing when Gravatar is disabled

Closes #34733 and #38715

See merge request gitlab-org/gitlab-ce!16681
parents 57892e6d ed341db2
...@@ -84,7 +84,7 @@ export default { ...@@ -84,7 +84,7 @@ export default {
return !this.showLess || (index < this.defaultRenderCount && this.showLess); return !this.showLess || (index < this.defaultRenderCount && this.showLess);
}, },
avatarUrl(user) { avatarUrl(user) {
return user.avatar || user.avatar_url; return user.avatar || user.avatar_url || gon.default_avatar_url;
}, },
assigneeUrl(user) { assigneeUrl(user) {
return `${this.rootPath}${user.username}`; return `${this.rootPath}${user.username}`;
......
...@@ -492,7 +492,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -492,7 +492,7 @@ function UsersSelect(currentUser, els, options = {}) {
renderRow: function(user) { renderRow: function(user) {
var avatar, img, listClosingTags, listWithName, listWithUserName, username; var avatar, img, listClosingTags, listWithName, listWithUserName, username;
username = user.username ? "@" + user.username : ""; username = user.username ? "@" + user.username : "";
avatar = user.avatar_url ? user.avatar_url : false; avatar = user.avatar_url ? user.avatar_url : gon.default_avatar_url;
let selected = false; let selected = false;
...@@ -513,9 +513,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -513,9 +513,7 @@ function UsersSelect(currentUser, els, options = {}) {
if (user.beforeDivider != null) { if (user.beforeDivider != null) {
`<li><a href='#' class='${selected === true ? 'is-active' : ''}'>${_.escape(user.name)}</a></li>`; `<li><a href='#' class='${selected === true ? 'is-active' : ''}'>${_.escape(user.name)}</a></li>`;
} else { } else {
if (avatar) { img = "<img src='" + avatar + "' class='avatar avatar-inline' width='32' />";
img = "<img src='" + avatar + "' class='avatar avatar-inline' width='32' />";
}
} }
return ` return `
......
...@@ -89,7 +89,7 @@ module ApplicationHelper ...@@ -89,7 +89,7 @@ module ApplicationHelper
end end
def default_avatar def default_avatar
'no_avatar.png' asset_path('no_avatar.png')
end end
def last_commit(project) def last_commit(project)
......
---
title: Fix default avatar icon missing when Gravatar is disabled
merge_request: 16681
author: Felix Geyer
type: fixed
...@@ -100,7 +100,7 @@ describe ApplicationHelper do ...@@ -100,7 +100,7 @@ describe ApplicationHelper do
end end
it 'returns a generic avatar' do it 'returns a generic avatar' do
expect(helper.gravatar_icon(user_email)).to match('no_avatar.png') expect(helper.gravatar_icon(user_email)).to match_asset_path('no_avatar.png')
end end
end end
...@@ -110,7 +110,7 @@ describe ApplicationHelper do ...@@ -110,7 +110,7 @@ describe ApplicationHelper do
end end
it 'returns a generic avatar when email is blank' do it 'returns a generic avatar when email is blank' do
expect(helper.gravatar_icon('')).to match('no_avatar.png') expect(helper.gravatar_icon('')).to match_asset_path('no_avatar.png')
end end
it 'returns a valid Gravatar URL' do it 'returns a valid Gravatar URL' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment