summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Brandl <abrandl@gitlab.com>2018-02-09 22:55:16 +0100
committerAndreas Brandl <abrandl@gitlab.com>2018-02-13 18:04:52 +0100
commit4f3d75326cb8a2f94a93bb3a32bf204ddfab806b (patch)
tree06d0eba4af0d40a0722f5ba002be3fa9300ec72f
parentc4cf7220146f74196ef20b12cf0db3502649ac06 (diff)
downloadgitlab-ce-4f3d75326cb8a2f94a93bb3a32bf204ddfab806b.tar.gz
Extract method to improve readability.
-rw-r--r--app/helpers/avatars_helper.rb18
1 files changed, 11 insertions, 7 deletions
diff --git a/app/helpers/avatars_helper.rb b/app/helpers/avatars_helper.rb
index 16e9fbfd3aa..21b6c0a8ad5 100644
--- a/app/helpers/avatars_helper.rb
+++ b/app/helpers/avatars_helper.rb
@@ -8,17 +8,21 @@ module AvatarsHelper
}))
end
+ def user_avatar_url_for(options = {})
+ if options[:url]
+ options[:url]
+ elsif options[:user]
+ avatar_icon_for_user(options[:user], options[:size])
+ else
+ avatar_icon_for_email(options[:user_email], options[:size])
+ end
+ end
+
def user_avatar_without_link(options = {})
avatar_size = options[:size] || 16
user_name = options[:user].try(:name) || options[:user_name]
- avatar_url = if options[:url]
- options[:url]
- elsif options[:user]
- avatar_icon_for_user(options[:user], avatar_size)
- else
- avatar_icon_for_email(options[:user_email], avatar_size)
- end
+ avatar_url = user_avatar_url_for(options.merge(size: avatar_size))
has_tooltip = options[:has_tooltip].nil? ? true : options[:has_tooltip]
data_attributes = options[:data] || {}