1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-10-17 17:01:01 +00:00

Adds method @initials@ to @Principal@ and return @nil@ by default (#42623).

git-svn-id: https://svn.redmine.org/redmine/trunk@23888 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Marius Balteanu 2025-07-15 05:20:23 +00:00
parent e940540e2e
commit ae3cb747bb
3 changed files with 10 additions and 1 deletions

View File

@ -44,7 +44,7 @@ module AvatarsHelper
if user.respond_to?(:mail)
email = user.mail
options[:title] = user.name unless options[:title]
options[:initials] = user.initials if options[:default] == "initials"
options[:initials] = user.initials if options[:default] == "initials" && user.initials.present?
elsif user.to_s =~ %r{<(.+?)>}
email = $1
end

View File

@ -130,6 +130,11 @@ class Principal < ApplicationRecord
to_s
end
# Returns nil by default, subclasses should implement this method
def initials(formatter = nil)
nil
end
def mail=(*args)
nil
end

View File

@ -166,4 +166,8 @@ class PrincipalTest < ActiveSupport::TestCase
r = Principal.like('vi_ci')
assert_include user, r
end
def test_initials_should_return_nil
assert_nil Group.first.initials
end
end