diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-01-24 09:23:11 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-01-24 09:23:11 +0000 |
commit | 6e6c6fac5caf92103a54e0c8f76a06f5f1b3b4f4 (patch) | |
tree | 1e4b7ed8548d41f978fe9b1a236716eae5a17dd8 | |
parent | 4b5ce4c089eef1251bf724fb4ae6ca733684320d (diff) | |
download | redmine-6e6c6fac5caf92103a54e0c8f76a06f5f1b3b4f4.tar.gz redmine-6e6c6fac5caf92103a54e0c8f76a06f5f1b3b4f4.zip |
Adds firstname initials+lastname user format.
git-svn-id: http://svn.redmine.org/redmine/trunk@12690 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/models/user.rb | 5 | ||||
-rw-r--r-- | test/unit/user_test.rb | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 189a9d9d6..d04369277 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -32,6 +32,11 @@ class User < Principal :order => %w(firstname lastname id), :setting_order => 2 }, + :firstinitial_lastname => { + :string => '#{firstname.to_s.gsub(/(([[:alpha:]])[[:alpha:]]*\.?)/, \'\2.\')} #{lastname}', + :order => %w(firstname lastname id), + :setting_order => 2 + }, :firstname => { :string => '#{firstname}', :order => %w(firstname id), diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 4e11ffecc..6e995b7e2 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -442,6 +442,11 @@ class UserTest < ActiveSupport::TestCase def test_name_format assert_equal 'John S.', @jsmith.name(:firstname_lastinitial) assert_equal 'Smith, John', @jsmith.name(:lastname_coma_firstname) + assert_equal 'J. Smith', @jsmith.name(:firstinitial_lastname) + assert_equal 'J.-P. Lang', User.new(:firstname => 'Jean-Philippe', :lastname => 'Lang').name(:firstinitial_lastname) + end + + def test_name_should_use_setting_as_default_format with_settings :user_format => :firstname_lastname do assert_equal 'John Smith', @jsmith.reload.name end |