Make email address voluntary in preferences; update tests to handle the added email field better

This commit is contained in:
Jyri-Petteri Paloposki 2020-07-20 20:08:18 +03:00
parent f9f7e6b9ea
commit efee4976b0
5 changed files with 71 additions and 21 deletions

View file

@ -107,7 +107,7 @@ class User < ApplicationRecord
validates_length_of :login, within: 3..80
validates_uniqueness_of :login, on: :create
validate :validate_auth_type
validates :email, format: { with: URI::MailTo::EMAIL_REGEXP }
validates :email, :allow_blank => true, format: { with: URI::MailTo::EMAIL_REGEXP }
before_create :crypt_password, :generate_token
before_update :crypt_password