mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Merge pull request #2148 from kukula/master
Fix default email_regexp config to not allow spaces
This commit is contained in:
commit
3696cbf33e
2 changed files with 13 additions and 2 deletions
|
@ -87,7 +87,7 @@ module Devise
|
|||
# an one (and only one) @ exists in the given string. This is mainly
|
||||
# to give user feedback and not to assert the e-mail validity.
|
||||
mattr_accessor :email_regexp
|
||||
@@email_regexp = /\A[^@]+@([^@\.]+\.)+[^@\.]+\z/
|
||||
@@email_regexp = /\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/
|
||||
|
||||
# Range validation for password length
|
||||
mattr_accessor :password_length
|
||||
|
|
|
@ -68,5 +68,16 @@ class DeviseTest < ActiveSupport::TestCase
|
|||
end
|
||||
assert_not Devise.secure_compare("size_1", "size_four")
|
||||
end
|
||||
|
||||
|
||||
test 'Devise.email_regexp should match valid email addresses' do
|
||||
valid_emails = ["test@example.com", "jo@jo.co", "f4$_m@you.com", "testing.example@example.com.ua"]
|
||||
non_valid_emails = ["rex", "test@go,com", "test user@example.com", "test_user@example server.com"]
|
||||
|
||||
valid_emails.each do |email|
|
||||
assert_match Devise.email_regexp, email
|
||||
end
|
||||
non_valid_emails.each do |email|
|
||||
assert_no_match Devise.email_regexp, email
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue