hotsh / rstat.us

Simple microblogging network based on the ostatus protocol.
http://rstat.us/
Other
722 stars 215 forks source link

Validate :email in User model using email_validator gem #831

Closed pdostal closed 6 years ago

pdostal commented 9 years ago

747: I planned to validate :email using some regex expression, but as you can see here, it's not so easy - so I used email_validator gem - Is it OK? :smile: :email: :christmas_tree:

colindean commented 9 years ago

Can you run the tests locally? There are several failures that look like they are related to emails not validating when maybe they should. Also possible that those tests need to be updated with a valid email.

pdostal commented 9 years ago

Sorry, these tests are too complicated for me. Can you point me what I have to exactly do? It only validatites :email in User model, so it should be accessible even in tests. In fabricators are valid addresses so I really don't know where is problem :/

wilkie commented 9 years ago

We don't require an email address. So it fails to validate for any test that doesn't provide one. You have to apply a validation that allows email to be blank:

validates :email, :email => true, :allow_blank => true

After this, one test now errors because the validator finds "new_email@new_email.com" to be invalid (probably due to domain rules about underscores). So, we just need to fix the fake email address in that test to just "new_email@newemail.com"

After that, they should all pass! :)

pdostal commented 9 years ago

:open_mouth: now it makes sense! Thanks you @wilkie :+1:

I'll watch and try to solve something by myself :)