From 8f93f08e1c4a22d5ea8fe47271cd9d46b4112a8f Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 7 Jan 2018 22:06:11 +0000 Subject: [PATCH] Merged r17150 to 3.3-stable (#26699). git-svn-id: http://svn.redmine.org/redmine/branches/3.3-stable@17152 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/application_helper.rb | 8 +++++++- public/images/anonymous.png | Bin 0 -> 1072 bytes test/unit/helpers/application_helper_test.rb | 7 +++++-- 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 public/images/anonymous.png diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0c85598e0..6889ba231 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1278,7 +1278,13 @@ module ApplicationHelper elsif user.to_s =~ %r{<(.+?)>} email = $1 end - return gravatar(email.to_s.downcase, options) unless email.blank? rescue nil + if email.present? + gravatar(email.to_s.downcase, options) rescue nil + else + image_tag 'anonymous.png', + GravatarHelper::DEFAULT_OPTIONS + .except(:default, :rating, :ssl).merge(options) + end else '' end diff --git a/public/images/anonymous.png b/public/images/anonymous.png new file mode 100644 index 0000000000000000000000000000000000000000..5f00a8362b23277c1da58e0be91251586c129744 GIT binary patch literal 1072 zcmV-01kd}4P)C0000PbVXQnQ*UN; zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBUyGf+%aMegqIx3{;$!^7Iz+SAk1zrVlY z;^MozyXxxd%gf8==H|!8$JW-?-rnBN&(HGm^0TwELdmxJ000A%NklqeF00I~L{p51dIv`{L6qdlB3=coV0Zco zX$W;I5K+ACxm2wHkoPanhmjMjZ3NH-{?X+UjR3O1KMH#^0xWd@D@$i+9YFdb5bn&l zf3F$=(nXN>ABsd305$%Cpi-{`aEkw)0B4Es{wn|i1!nyK60hE9wc4)?b$km7D|G;X zAZF^@QmjdGy)*(O@_UiLEUA`TBY^ddrW*l1Od~+^iD+r_@0tPjv;#xmu4|9waVg@T zM_wyaItc9mM>fB$sxCqbfX#OUfz{Rk>2ivvp~+s~Xl)t-fF%eFs|^6DL9yiD&1(Zd z0zj7-@{G*B1b}J*0f5xGr?u%^%@WWWg){)9QJhUeVzZXmDSe*$b7jbg?P_XI`AHCj z0J{~7k9PqO0+E^|Q2iGSES?05jn1*i{!2zS>(i0pocsFqFP#|yryW96$qbdyCsgO` zVWW)A&TVp0q8Z?GflmVKvMsaqB9Er6MWfAQ{-TrX5R7tu*M`y60N~Imn2w%PUEnJ? zCMCy+iSPDs!C4qe*pM)&%l!WOmQ$ACN zst!GKQeV?vOP7~vMFSw;hdFmY`V)?G>Ms@wfbbnn_|7KM z0Kj?!+|>YzhjgtbQvm$~@CX5n4!}JGK<$mc7=k!}@Iy>Q0o)h>7Xtu4$RGkBMgfQj zfExwiA^>a@0K)-RKg?DXK#T(rD8Mle;6MTRH~@|UsBr)a1@HrH0(?0D{PzGe2PVJ- qm;e)C0!)AjFaajOUj* '1' do assert avatar(User.find_by_mail('jsmith@somenet.foo')).include?(Digest::MD5.hexdigest('jsmith@somenet.foo')) assert avatar('jsmith ').include?(Digest::MD5.hexdigest('jsmith@somenet.foo')) @@ -1302,8 +1303,10 @@ RAW # The default class of the img tag should be gravatar assert avatar('jsmith ').include?('class="gravatar"') assert !avatar('jsmith ', :class => 'picture').include?('class="gravatar"') - assert_nil avatar('jsmith') - assert_nil avatar(nil) + assert_match tag_for_anonymous_re, avatar('jsmith') + assert_match tag_for_anonymous_re, avatar(nil) + # Avatar for anonymous user + assert_match tag_for_anonymous_re, avatar(User.anonymous) end end -- 2.39.5