Add email validation to Signup
This commit is contained in:
@@ -6,9 +6,8 @@ class Signup
|
||||
attr_accessor :full_name, :email_address, :identity
|
||||
attr_reader :account, :user
|
||||
|
||||
with_options on: :completion do
|
||||
validates_presence_of :full_name, :identity
|
||||
end
|
||||
validates :email_address, format: { with: URI::MailTo::EMAIL_REGEXP }, on: :identity_creation
|
||||
validates :full_name, :identity, presence: true, on: :completion
|
||||
|
||||
def initialize(...)
|
||||
super
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
require "test_helper"
|
||||
|
||||
class SignupTest < ActiveSupport::TestCase
|
||||
test "validates email format for identity creation" do
|
||||
signup = Signup.new(email_address: "not-an-email")
|
||||
assert_not signup.valid?(:identity_creation)
|
||||
assert signup.errors[:email_address].any?
|
||||
|
||||
signup = Signup.new(email_address: "valid@example.com")
|
||||
assert signup.valid?(:identity_creation)
|
||||
end
|
||||
|
||||
test "#create_identity" do
|
||||
signup = Signup.new(email_address: "brian@example.com")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user