Index: app/helpers/application_helper.rb =================================================================== --- app/helpers/application_helper.rb (revision 17198) +++ app/helpers/application_helper.rb (working copy) @@ -1407,10 +1407,12 @@ 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: test/helpers/application_helper_test.rb =================================================================== --- test/helpers/application_helper_test.rb (revision 17198) +++ test/helpers/application_helper_test.rb (working copy) @@ -1302,7 +1302,6 @@ 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 ').include?(Digest::MD5.hexdigest('jsmith@somenet.foo')) @@ -1314,10 +1313,12 @@ # 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_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) end end