Project

General

Profile

Defect #28208 » 28208.diff

patch (no avatar for groups) - Go MAEDA, 2018-02-18 03:19

View differences:

app/helpers/application_helper.rb (working copy)
1407 1407
      end
1408 1408
      if email.present?
1409 1409
        gravatar(email.to_s.downcase, options) rescue nil
1410
      else
1410
      elsif user.is_a?(AnonymousUser)
1411 1411
        image_tag 'anonymous.png',
1412 1412
                  GravatarHelper::DEFAULT_OPTIONS
1413 1413
                    .except(:default, :rating, :ssl).merge(options)
1414
      else
1415
        nil
1414 1416
      end
1415 1417
    else
1416 1418
      ''
test/helpers/application_helper_test.rb (working copy)
1302 1302
  end
1303 1303

  
1304 1304
  def test_avatar_enabled
1305
    tag_for_anonymous_re = %r{src="/images/anonymous.png(\?\d+)?"}
1306 1305
    with_settings :gravatar_enabled => '1' do
1307 1306
      assert avatar(User.find_by_mail('jsmith@somenet.foo')).include?(Digest::MD5.hexdigest('jsmith@somenet.foo'))
1308 1307
      assert avatar('jsmith <jsmith@somenet.foo>').include?(Digest::MD5.hexdigest('jsmith@somenet.foo'))
......
1314 1313
      # The default class of the img tag should be gravatar
1315 1314
      assert avatar('jsmith <jsmith@somenet.foo>').include?('class="gravatar"')
1316 1315
      assert !avatar('jsmith <jsmith@somenet.foo>', :class => 'picture').include?('class="gravatar"')
1317
      assert_match tag_for_anonymous_re, avatar('jsmith')
1318
      assert_match tag_for_anonymous_re, avatar(nil)
1316
      assert_nil avatar('jsmith')
1317
      assert_nil avatar(nil)
1319 1318
      # Avatar for anonymous user
1320
      assert_match tag_for_anonymous_re, avatar(User.anonymous)
1319
      assert_match %r{src="/images/anonymous.png(\?\d+)?"}, avatar(User.anonymous)
1320
      # No avatar for groups
1321
      assert_nil avatar(Group.first)
1321 1322
    end
1322 1323
  end
1323 1324

  
(2-2/2)