From 94039bd7ca750446c637b924547493cfe8143716 Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Tue, 23 Jan 2018 23:25:44 +0100 Subject: [PATCH 1/3] Make default_avatar return a full path. Callers expect a URL. This fixes the avatars in commit lists when a user has no avatar and Gravatar is disabled. Closes #38715 --- app/helpers/application_helper.rb | 2 +- spec/helpers/application_helper_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d13407a06c8..6530327698b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -89,7 +89,7 @@ module ApplicationHelper end def default_avatar - 'no_avatar.png' + asset_path('no_avatar.png') end def last_commit(project) diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index da0343588ef..f7a4a7afced 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -100,7 +100,7 @@ describe ApplicationHelper do end 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 @@ -110,7 +110,7 @@ describe ApplicationHelper do end 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 it 'returns a valid Gravatar URL' do From 65497b5f65ac115bb0219e83523f192fd51c91f2 Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Tue, 23 Jan 2018 23:29:20 +0100 Subject: [PATCH 2/3] Fall back to default_avatar_url in issue assigment. This fixes the avatar in issue assignments when the user hasn't got an avatar and Gravatar is disabled. Closes #34733 --- .../javascripts/sidebar/components/assignees/assignees.js | 2 +- app/assets/javascripts/users_select.js | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/sidebar/components/assignees/assignees.js b/app/assets/javascripts/sidebar/components/assignees/assignees.js index 7e5feac622c..643877b9d47 100644 --- a/app/assets/javascripts/sidebar/components/assignees/assignees.js +++ b/app/assets/javascripts/sidebar/components/assignees/assignees.js @@ -84,7 +84,7 @@ export default { return !this.showLess || (index < this.defaultRenderCount && this.showLess); }, avatarUrl(user) { - return user.avatar || user.avatar_url; + return user.avatar || user.avatar_url || gon.default_avatar_url; }, assigneeUrl(user) { return `${this.rootPath}${user.username}`; diff --git a/app/assets/javascripts/users_select.js b/app/assets/javascripts/users_select.js index f249bd036d6..ab108906732 100644 --- a/app/assets/javascripts/users_select.js +++ b/app/assets/javascripts/users_select.js @@ -492,7 +492,7 @@ function UsersSelect(currentUser, els, options = {}) { renderRow: function(user) { var avatar, img, listClosingTags, listWithName, listWithUserName, 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; @@ -513,9 +513,7 @@ function UsersSelect(currentUser, els, options = {}) { if (user.beforeDivider != null) { `
  • ${_.escape(user.name)}
  • `; } else { - if (avatar) { - img = ""; - } + img = ""; } return ` From ed341db24fac8ce62513c3953da8097ba8920271 Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Wed, 24 Jan 2018 17:49:08 +0100 Subject: [PATCH 3/3] Add changelog entry for !16681 --- .../34733-fix-default-avatar-when-gravatar-disabled.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelogs/unreleased/34733-fix-default-avatar-when-gravatar-disabled.yml diff --git a/changelogs/unreleased/34733-fix-default-avatar-when-gravatar-disabled.yml b/changelogs/unreleased/34733-fix-default-avatar-when-gravatar-disabled.yml new file mode 100644 index 00000000000..0791847b64d --- /dev/null +++ b/changelogs/unreleased/34733-fix-default-avatar-when-gravatar-disabled.yml @@ -0,0 +1,5 @@ +--- +title: Fix default avatar icon missing when Gravatar is disabled +merge_request: 16681 +author: Felix Geyer +type: fixed