]> source.dussan.org Git - redmine.git/commitdiff
Anonymous icon is wrongly displayed when assignee is a group (#28208).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 7 Apr 2018 07:25:27 +0000 (07:25 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 7 Apr 2018 07:25:27 +0000 (07:25 +0000)
Patch by Go MAEDA.

git-svn-id: http://svn.redmine.org/redmine/trunk@17263 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/application_helper.rb
test/helpers/application_helper_test.rb

index 9da044c040eeb5b2fb56e34c7a438edce61fce84..00992a5bb9e5272057e022e129343c9670aed71e 100644 (file)
@@ -1407,10 +1407,12 @@ module ApplicationHelper
       end
       if email.present?
         gravatar(email.to_s.downcase, options) rescue nil
-      else
+      elsif user.is_a?(AnonymousUser)
         image_tag 'anonymous.png',
                   GravatarHelper::DEFAULT_OPTIONS
                     .except(:default, :rating, :ssl).merge(options)
+      else
+        nil
       end
     else
       ''
index 81b3f7859954a513238989f4499405310c062fa4..d8e4687417a5bc7604f5098a2f1a779bc671f69d 100644 (file)
@@ -1287,7 +1287,6 @@ RAW
   end
 
   def test_avatar_enabled
-    tag_for_anonymous_re = %r{src="/images/anonymous.png(\?\d+)?"}
     with_settings :gravatar_enabled => '1' do
       assert avatar(User.find_by_mail('jsmith@somenet.foo')).include?(Digest::MD5.hexdigest('jsmith@somenet.foo'))
       assert avatar('jsmith <jsmith@somenet.foo>').include?(Digest::MD5.hexdigest('jsmith@somenet.foo'))
@@ -1299,10 +1298,12 @@ RAW
       # The default class of the img tag should be gravatar
       assert avatar('jsmith <jsmith@somenet.foo>').include?('class="gravatar"')
       assert !avatar('jsmith <jsmith@somenet.foo>', :class => 'picture').include?('class="gravatar"')
-      assert_match tag_for_anonymous_re, avatar('jsmith')
-      assert_match tag_for_anonymous_re, avatar(nil)
+      assert_nil avatar('jsmith')
+      assert_nil avatar(nil)
       # Avatar for anonymous user
-      assert_match tag_for_anonymous_re, avatar(User.anonymous)
+      assert_match %r{src="/images/anonymous.png(\?\d+)?"}, avatar(User.anonymous)
+      # No avatar for groups
+      assert_nil avatar(Group.first)
       assert avatar(User.anonymous, :size => 24).include?('width="24" height="24"')
     end
   end