35823.patch

Go MAEDA, 2021-09-04 10:24

Download (2.9 KB)

View differences:

app/helpers/application_helper.rb
60 60
    case principal
61 61
    when User
62 62
      name = h(principal.name(options[:format]))
63
      css_classes = ''
63 64
      if principal.active? || (User.current.admin? && principal.logged?)
64 65
        url = user_url(principal, :only_path => only_path)
65
        css_classes = principal.css_classes
66
        css_classes += principal.css_classes
66 67
      end
67 68
    when Group
68 69
      name = h(principal.to_s)
69 70
      url = group_url(principal, :only_path => only_path)
70
      css_classes = 'group'
71
      css_classes = principal.css_classes
71 72
    else
72 73
      name = h(principal.to_s)
73 74
    end
74 75

  
75
    css_classes += " #{options[:class]}" if options[:class].present?
76
    css_classes += " #{options[:class]}" if css_classes && options[:class].present?
76 77
    url ? link_to(name, url, :class => css_classes) : name
77 78
  end
78 79

  
app/models/group.rb
73 73
    !builtin?
74 74
  end
75 75

  
76
  def css_classes
77
    'group'
78
  end
79

  
76 80
  def user_added(user)
77 81
    members.each do |member|
78 82
      next if member.project.nil?
test/helpers/application_helper_test.rb
1701 1701
    end
1702 1702
  end
1703 1703

  
1704
  def test_link_to_user_should_link_to_locked_user_if_current_user_is_admin
1704
  def test_link_to_user_should_link_to_locked_user_only_if_current_user_is_admin
1705
    user = User.find(5)
1706
    assert user.locked?
1707

  
1705 1708
    with_current_user User.find(1) do
1706
      user = User.find(5)
1707
      assert user.locked?
1708
      result = link_to("Dave2 Lopper2", "/users/5", :class => "user locked")
1709
      assert_equal result, link_to_user(user)
1709
      result = link_to('Dave2 Lopper2', '/users/5', :class => 'user locked assigned_to')
1710
      assert_equal result, link_to_user(user, :class => 'assigned_to')
1711
    end
1712

  
1713
    with_current_user User.find(2) do
1714
      result = 'Dave2 Lopper2'
1715
      assert_equal result, link_to_user(user, :class => 'assigned_to')
1710 1716
    end
1711 1717
  end
1712 1718

  
......
1722 1728
    assert_equal result, link_to_principal(group)
1723 1729
  end
1724 1730

  
1731
  def test_link_to_principal_should_return_string_representation_for_unknown_type_principal
1732
    unknown_principal = 'foo'
1733
    result = unknown_principal.to_s
1734
    assert_equal result, link_to_principal(unknown_principal, :class => 'bar')
1735
  end
1736

  
1725 1737
  def test_link_to_group_should_return_only_group_name_for_non_admin_users
1726 1738
    User.current = nil
1727 1739
    group = Group.find(10)