@@ -32,6 +32,11 class User < Principal | |||
|
32 | 32 | :order => %w(firstname lastname id), |
|
33 | 33 | :setting_order => 2 |
|
34 | 34 | }, |
|
35 | :firstinitial_lastname => { | |
|
36 | :string => '#{firstname.to_s.gsub(/(([[:alpha:]])[[:alpha:]]*\.?)/, \'\2.\')} #{lastname}', | |
|
37 | :order => %w(firstname lastname id), | |
|
38 | :setting_order => 2 | |
|
39 | }, | |
|
35 | 40 | :firstname => { |
|
36 | 41 | :string => '#{firstname}', |
|
37 | 42 | :order => %w(firstname id), |
@@ -442,6 +442,11 class UserTest < ActiveSupport::TestCase | |||
|
442 | 442 | def test_name_format |
|
443 | 443 | assert_equal 'John S.', @jsmith.name(:firstname_lastinitial) |
|
444 | 444 | assert_equal 'Smith, John', @jsmith.name(:lastname_coma_firstname) |
|
445 | assert_equal 'J. Smith', @jsmith.name(:firstinitial_lastname) | |
|
446 | assert_equal 'J.-P. Lang', User.new(:firstname => 'Jean-Philippe', :lastname => 'Lang').name(:firstinitial_lastname) | |
|
447 | end | |
|
448 | ||
|
449 | def test_name_should_use_setting_as_default_format | |
|
445 | 450 | with_settings :user_format => :firstname_lastname do |
|
446 | 451 | assert_equal 'John Smith', @jsmith.reload.name |
|
447 | 452 | end |
General Comments 0
You need to be logged in to leave comments.
Login now