New user name format: firstname + first letter of lastname (#12085).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10770 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-10-30 08:40:12 +00:00
parent cdc8944a89
commit 399223daba
2 changed files with 11 additions and 5 deletions

View File

@ -33,30 +33,35 @@ class User < Principal
:order => %w(firstname lastname id), :order => %w(firstname lastname id),
:setting_order => 1 :setting_order => 1
}, },
:firstname_lastinitial => {
:string => '#{firstname} #{lastname.to_s.chars.first}.',
:order => %w(firstname lastname id),
:setting_order => 2
},
:firstname => { :firstname => {
:string => '#{firstname}', :string => '#{firstname}',
:order => %w(firstname id), :order => %w(firstname id),
:setting_order => 2 :setting_order => 3
}, },
:lastname_firstname => { :lastname_firstname => {
:string => '#{lastname} #{firstname}', :string => '#{lastname} #{firstname}',
:order => %w(lastname firstname id), :order => %w(lastname firstname id),
:setting_order => 3 :setting_order => 4
}, },
:lastname_coma_firstname => { :lastname_coma_firstname => {
:string => '#{lastname}, #{firstname}', :string => '#{lastname}, #{firstname}',
:order => %w(lastname firstname id), :order => %w(lastname firstname id),
:setting_order => 4 :setting_order => 5
}, },
:lastname => { :lastname => {
:string => '#{lastname}', :string => '#{lastname}',
:order => %w(lastname id), :order => %w(lastname id),
:setting_order => 5 :setting_order => 6
}, },
:username => { :username => {
:string => '#{login}', :string => '#{login}',
:order => %w(login id), :order => %w(login id),
:setting_order => 6 :setting_order => 7
}, },
} }

View File

@ -410,6 +410,7 @@ class UserTest < ActiveSupport::TestCase
end end
def test_name_format def test_name_format
assert_equal 'John S.', @jsmith.name(:firstname_lastinitial)
assert_equal 'Smith, John', @jsmith.name(:lastname_coma_firstname) assert_equal 'Smith, John', @jsmith.name(:lastname_coma_firstname)
with_settings :user_format => :firstname_lastname do with_settings :user_format => :firstname_lastname do
assert_equal 'John Smith', @jsmith.reload.name assert_equal 'John Smith', @jsmith.reload.name