Project

General

Profile

Defect #41853 » fix-41853.patch

Takenori TAKAKI, 2024-11-29 02:52

View differences:

app/assets/stylesheets/application.css
433 433

  
434 434
tr.member td.icon-user, #principals_for_new_member .icon-user {background:transparent;}
435 435
#principals_for_new_member svg {margin-right: 4px;}
436
#principals_for_new_member img.gravatar {margin-right: 4px;}
437
#principals_for_new_member span.icon:empty { display: none; }
436 438

  
437 439
tr.user td {width:13%;white-space: nowrap;}
438 440
td.username, td.firstname, td.lastname, td.email {text-align:left !important;}
......
537 539

  
538 540
#watchers select {width: 95%; display: block;}
539 541
#watchers img.gravatar {margin: 0 4px 2px 0;}
542
#watchers svg.icon-svg {margin: 0 2px 2px 0;}
540 543
#users_for_watcher img.gravatar {padding-bottom: 2px; margin-right: 4px;}
544
#users_for_watcher svg.icon-svg {padding-bottom: 2px; margin-right: 2px;}
545
#users_for_watcher span.icon:empty { display: none; }
541 546

  
542 547
span#watchers_inputs {overflow:auto; display:block;}
543 548
span.search_for_watchers {display:block;}
app/helpers/application_helper.rb
651 651
  def principals_check_box_tags(name, principals)
652 652
    s = +''
653 653
    principals.each do |principal|
654
      s <<
655
        content_tag(
656
          'label',
657
          check_box_tag(name, principal.id, false, :id => nil) +
658
            (avatar(principal, :size => 16).presence ||
659
               content_tag(
660
                 'span', principal_icon(principal),
661
                 :class => "name icon icon-#{principal.class.name.downcase}"
662
               )
663
            ) + principal.to_s
664
        )
654
      principal_check_box = +''
655
      principal_check_box << check_box_tag(name, principal.id, false, :id => nil)
656
      principal_check_box << avatar(principal, :size => 16).to_s if principal.is_a?(User)
657
      principal_check_box << content_tag('span', principal_icon(principal), :class => "name icon icon-#{principal.class.to_s.downcase}")
658
      principal_check_box << principal.to_s
659
      s << content_tag('label', principal_check_box.html_safe)
665 660
    end
666 661
    s.html_safe
667 662
  end
app/helpers/watchers_helper.rb
49 49
    content = ''.html_safe
50 50
    lis = object.watcher_users.sorted.collect do |user|
51 51
      s = ''.html_safe
52
      s << avatar(user, :size => "16").to_s
52
      s << avatar(user, :size => "16").to_s if user.is_a?(User)
53 53
      s << link_to_principal(user, class: user.class.to_s.downcase)
54 54
      if object.respond_to?(:visible?) && user.is_a?(User) && !object.visible?(user)
55 55
        s << content_tag('span', l(:notice_invalid_watcher), class: 'icon-only icon-warning', title: l(:notice_invalid_watcher))
test/helpers/application_helper_test.rb
2008 2008
  end
2009 2009

  
2010 2010
  def test_principals_check_box_tag_with_avatar
2011
    principals = [User.find(1), Group.find(10)]
2011
    principals = [User.find(1), User.find(2)]
2012 2012
    with_settings :gravatar_enabled => '1' do
2013 2013
      tags = principals_check_box_tags("watcher[user_ids][]", principals)
2014 2014
      principals.each do |principal|
2015 2015
        assert_include avatar(principal, :size => 16), tags
2016
        assert_not_include content_tag('span', nil, :class => "name icon icon-#{principal.class.name.downcase}"), tags
2016
        assert_include content_tag('span', nil, :class => "name icon icon-#{principal.class.name.downcase}"), tags
2017
        assert_include principal.to_s, tags
2017 2018
      end
2018 2019
    end
2019 2020
  end
2020 2021

  
2021
  def test_principals_check_box_tag_without_avatar
2022
    principals = [User.find(1), Group.find(10)]
2022
  def test_principals_check_box_tag_without_avatar_when_principal_is_group
2023
    principals = [Group.find(10), Group.find(11)]
2024
    with_settings :gravatar_enabled => '1' do
2025
      tags = principals_check_box_tags("watcher[user_ids][]", principals)
2026
      principals.each do |principal|
2027
        assert_not_include avatar(principal, :size => 16), tags
2028
        assert_include content_tag('span', principal_icon(principal), :class => "name icon icon-#{principal.class.name.downcase}"), tags
2029
        assert_include principal.to_s, tags
2030
      end
2031
    end
2032
  end
2033

  
2034
  def test_principals_check_box_tag_without_avatar_when_gravatar_disabled
2035
    principals = [User.find(1), User.find(2)]
2023 2036
    Setting.gravatar_enabled = '1'
2024 2037
    avatar_tags = principals.collect{|p| avatar(p, :size => 16)}
2025 2038

  
......
2027 2040
      tags = principals_check_box_tags(name, principals)
2028 2041
      principals.each_with_index do |principal, i|
2029 2042
        assert_not_include avatar_tags[i], tags
2030
        assert_include content_tag('span', principal_icon(principal), :class => "name icon icon-#{principal.class.name.downcase}"), tags
2043
        assert_include content_tag('span', nil, :class => "name icon icon-#{principal.class.name.downcase}"), tags
2044
        assert_include principal.to_s, tags
2031 2045
      end
2032 2046
    end
2033 2047
  end
test/helpers/watchers_helper_test.rb
94 94
      end
95 95
    end
96 96
  end
97

  
98
  def test_watchers_list_should_include_avatar_and_user_name
99
    issue = Issue.find(1)
100
    Watcher.create!(:watchable => issue, :user => User.find(1))
101

  
102
    with_settings :gravatar_enabled => '1' do
103
      result = watchers_list(issue)
104
      assert_select_in result, 'ul.watchers' do
105
        assert_select 'li', 1
106
        assert_select 'li:nth-of-type(1)>img.gravatar', 1
107
        assert_select 'li:nth-of-type(1)>a[href=?]', '/users/1', text: 'Redmine Admin'
108
        assert_select 'li:nth-of-type(1)>a.group>svg.icon-svg', 0
109
      end
110
    end
111
  end
112

  
113
  def test_watchers_list_should_include_svg_icon_and_group_name
114
    issue = Issue.find(1)
115
    Watcher.create!(:watchable => issue, :user => Group.find(10))
116

  
117
    with_settings :gravatar_enabled => '1' do
118
      result = watchers_list(issue)
119
      assert_select_in result, 'ul.watchers' do
120
        assert_select 'li', 1
121
        assert_select 'li:nth-of-type(1)>a.group>svg.icon-svg', 1
122
        assert_select 'li:nth-of-type(1)>a[href=?]', '/groups/10', text: 'A Team'
123
        assert_select 'li:nth-of-type(1)>img.gravatar', 0
124
      end
125
    end
126
  end
97 127
end
(6-6/8)