Fixed check_name().
This commit is contained in:
parent
3c7943dc27
commit
f723ea3cdb
2 changed files with 32 additions and 2 deletions
|
@ -333,7 +333,7 @@ Your #{config.product_name} Team
|
|||
|
||||
def check_name
|
||||
|
||||
if !self.firstname.empty? && self.lastname.empty?
|
||||
if ( self.firstname && !self.firstname.empty? ) && ( !self.lastname || self.lastname.empty? )
|
||||
|
||||
# Lastname, Firstname
|
||||
scan = self.firstname.scan(/, /)
|
||||
|
@ -351,7 +351,7 @@ Your #{config.product_name} Team
|
|||
return
|
||||
|
||||
# -no name- firstname.lastname@example.com
|
||||
elsif self.firstname.empty? && self.lastname.empty? && !self.email.empty?
|
||||
elsif ( !self.firstname || self.firstname.empty? ) && ( !self.lastname || self.lastname.empty? ) && ( self.email && !self.email.empty? )
|
||||
scan = self.email.scan(/^(.+?)\.(.+?)\@.+?$/)
|
||||
if scan[0]
|
||||
self.firstname = scan[0][0].capitalize
|
||||
|
|
|
@ -34,6 +34,21 @@ class UserTest < ActiveSupport::TestCase
|
|||
:login => 'some@example.com',
|
||||
},
|
||||
},
|
||||
{
|
||||
:create => {
|
||||
:firstname => 'Firstname Lastname',
|
||||
:lastname => nil,
|
||||
:email => 'some@example.com',
|
||||
:login => 'some@example.com',
|
||||
:created_by_id => 1,
|
||||
},
|
||||
:create_verify => {
|
||||
:firstname => 'Firstname',
|
||||
:lastname => 'Lastname',
|
||||
:email => 'some@example.com',
|
||||
:login => 'some@example.com',
|
||||
},
|
||||
},
|
||||
{
|
||||
:create => {
|
||||
:firstname => 'Lastname, Firstname',
|
||||
|
@ -79,6 +94,21 @@ class UserTest < ActiveSupport::TestCase
|
|||
:login => 'login',
|
||||
},
|
||||
},
|
||||
{
|
||||
:create => {
|
||||
:firstname => nil,
|
||||
:lastname => nil,
|
||||
:email => 'FIRSTNAME.lastname@example.com',
|
||||
:login => 'login',
|
||||
:created_by_id => 1,
|
||||
},
|
||||
:create_verify => {
|
||||
:firstname => 'Firstname',
|
||||
:lastname => 'Lastname',
|
||||
:email => 'firstname.lastname@example.com',
|
||||
:login => 'login',
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
tests.each { |test|
|
||||
|
|
Loading…
Reference in a new issue