summaryrefslogtreecommitdiff
path: root/app/helpers/avatars_helper.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-09-28 06:58:30 -0400
committerStan Hu <stanhu@gmail.com>2018-09-28 07:39:58 -0400
commitb49e6b419acb3e8c129398167ec6b521fc686f8d (patch)
tree3b9256856b8becc0218b1055f19d637950ed0fd7 /app/helpers/avatars_helper.rb
parent790eabcaf4a703d2776a0c6e0c461d35598e37b1 (diff)
downloadgitlab-ce-b49e6b419acb3e8c129398167ec6b521fc686f8d.tar.gz
Fix Error 500 when forking projects with Gravatar disabledsh-fix-forks-with-no-gravatar
When Gravatar is disabled, the "no avatar" is used, which failed to revert to the colorful identity icons for namespaces. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/50254
Diffstat (limited to 'app/helpers/avatars_helper.rb')
-rw-r--r--app/helpers/avatars_helper.rb21
1 files changed, 8 insertions, 13 deletions
diff --git a/app/helpers/avatars_helper.rb b/app/helpers/avatars_helper.rb
index 321811a3ca3..7fc4c1a023f 100644
--- a/app/helpers/avatars_helper.rb
+++ b/app/helpers/avatars_helper.rb
@@ -1,12 +1,12 @@
# frozen_string_literal: true
module AvatarsHelper
- def project_icon(project_id, options = {})
- source_icon(Project, project_id, options)
+ def project_icon(project, options = {})
+ source_icon(project, options)
end
- def group_icon(group_id, options = {})
- source_icon(Group, group_id, options)
+ def group_icon(group, options = {})
+ source_icon(group, options)
end
# Takes both user and email and returns the avatar_icon by
@@ -110,16 +110,11 @@ module AvatarsHelper
private
- def source_icon(klass, source_id, options = {})
- source =
- if source_id.respond_to?(:avatar_url)
- source_id
- else
- klass.find_by_full_path(source_id)
- end
+ def source_icon(source, options = {})
+ avatar_url = source.try(:avatar_url)
- if source.avatar_url
- image_tag source.avatar_url, options
+ if avatar_url
+ image_tag avatar_url, options
else
source_identicon(source, options)
end