@@ -69,7 +69,7 class User < Principal | |||
|
69 | 69 | validates_format_of :login, :with => /^[a-z0-9_\-@\.]*$/i |
|
70 | 70 | validates_length_of :login, :maximum => 30 |
|
71 | 71 | validates_length_of :firstname, :lastname, :maximum => 30 |
|
72 |
validates_format_of :mail, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :allow_ |
|
|
72 | validates_format_of :mail, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :allow_blank => true | |
|
73 | 73 | validates_length_of :mail, :maximum => 60, :allow_nil => true |
|
74 | 74 | validates_confirmation_of :password, :allow_nil => true |
|
75 | 75 | validates_inclusion_of :mail_notification, :in => MAIL_NOTIFICATION_OPTIONS.collect(&:first), :allow_blank => true |
@@ -41,6 +41,13 class UserTest < ActiveSupport::TestCase | |||
|
41 | 41 | u.mail = " foo@bar.com " |
|
42 | 42 | assert_equal "foo@bar.com", u.mail |
|
43 | 43 | end |
|
44 | ||
|
45 | def test_mail_validation | |
|
46 | u = User.new | |
|
47 | u.mail = '' | |
|
48 | assert !u.valid? | |
|
49 | assert_equal I18n.translate('activerecord.errors.messages.blank'), u.errors.on(:mail) | |
|
50 | end | |
|
44 | 51 | |
|
45 | 52 | def test_create |
|
46 | 53 | user = User.new(:firstname => "new", :lastname => "user", :mail => "newuser@somenet.foo") |
General Comments 0
You need to be logged in to leave comments.
Login now