validates_presence_of :login, :firstname, :lastname, :mail, :if => Proc.new { |user| !user.is_a?(AnonymousUser) }
validates_uniqueness_of :login, :if => Proc.new { |user| !user.login.blank? }
- validates_uniqueness_of :mail, :if => Proc.new { |user| !user.mail.blank? }
+ validates_uniqueness_of :mail, :if => Proc.new { |user| !user.mail.blank? }, :case_sensitive => false
# Login must contain lettres, numbers, underscores only
validates_format_of :login, :with => /^[a-z0-9_\-@\.]*$/i
validates_length_of :login, :maximum => 30
\r
user.password, user.password_confirmation = "password", "password"\r
assert user.save\r
+ end
+
+ def test_mail_uniqueness_should_not_be_case_sensitive
+ u = User.new(:firstname => "new", :lastname => "user", :mail => "newuser@somenet.foo")
+ u.login = 'newuser1'
+ u.password, u.password_confirmation = "password", "password"
+ assert u.save
+
+ u = User.new(:firstname => "new", :lastname => "user", :mail => "newUser@Somenet.foo")
+ u.login = 'newuser2'
+ u.password, u.password_confirmation = "password", "password"
+ assert !u.save
+ assert_equal 'activerecord_error_taken', u.errors.on(:mail)
end\r
def test_update