Project

General

Profile

Feature #42623 » 42623-fix-principal-initials.patch

Marius BĂLTEANU, 2025-07-14 22:50

View differences:

app/helpers/avatars_helper.rb
44 44
      if user.respond_to?(:mail)
45 45
        email = user.mail
46 46
        options[:title] = user.name unless options[:title]
47
        options[:initials] = user.initials if options[:default] == "initials"
47
        options[:initials] = user.initials if options[:default] == "initials" && user.initials.present?
48 48
      elsif user.to_s =~ %r{<(.+?)>}
49 49
        email = $1
50 50
      end
app/models/principal.rb
130 130
    to_s
131 131
  end
132 132

  
133
  # Returns nil by default, subclasses should implement this method
134
  def initials(formatter = nil)
135
    nil
136
  end
137

  
133 138
  def mail=(*args)
134 139
    nil
135 140
  end
test/unit/principal_test.rb
166 166
    r = Principal.like('vi_ci')
167 167
    assert_include user, r
168 168
  end
169

  
170
  def test_initials_should_return_nil
171
    assert_nil Group.first.initials
172
  end
169 173
end
(4-4/4)