Do not show 2 validation errors when user mail is blank.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6168 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
37aba18c8f
commit
f2af44b6fe
|
@ -69,7 +69,7 @@ class User < Principal
|
||||||
validates_format_of :login, :with => /^[a-z0-9_\-@\.]*$/i
|
validates_format_of :login, :with => /^[a-z0-9_\-@\.]*$/i
|
||||||
validates_length_of :login, :maximum => 30
|
validates_length_of :login, :maximum => 30
|
||||||
validates_length_of :firstname, :lastname, :maximum => 30
|
validates_length_of :firstname, :lastname, :maximum => 30
|
||||||
validates_format_of :mail, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :allow_nil => true
|
validates_format_of :mail, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :allow_blank => true
|
||||||
validates_length_of :mail, :maximum => 60, :allow_nil => true
|
validates_length_of :mail, :maximum => 60, :allow_nil => true
|
||||||
validates_confirmation_of :password, :allow_nil => true
|
validates_confirmation_of :password, :allow_nil => true
|
||||||
validates_inclusion_of :mail_notification, :in => MAIL_NOTIFICATION_OPTIONS.collect(&:first), :allow_blank => true
|
validates_inclusion_of :mail_notification, :in => MAIL_NOTIFICATION_OPTIONS.collect(&:first), :allow_blank => true
|
||||||
|
|
|
@ -41,6 +41,13 @@ class UserTest < ActiveSupport::TestCase
|
||||||
u.mail = " foo@bar.com "
|
u.mail = " foo@bar.com "
|
||||||
assert_equal "foo@bar.com", u.mail
|
assert_equal "foo@bar.com", u.mail
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_mail_validation
|
||||||
|
u = User.new
|
||||||
|
u.mail = ''
|
||||||
|
assert !u.valid?
|
||||||
|
assert_equal I18n.translate('activerecord.errors.messages.blank'), u.errors.on(:mail)
|
||||||
|
end
|
||||||
|
|
||||||
def test_create
|
def test_create
|
||||||
user = User.new(:firstname => "new", :lastname => "user", :mail => "newuser@somenet.foo")
|
user = User.new(:firstname => "new", :lastname => "user", :mail => "newuser@somenet.foo")
|
||||||
|
|
Loading…
Reference in New Issue