From bf6233c14b5fe64ec2fc6d9f98ed5000fa3a81c7 Mon Sep 17 00:00:00 2001 From: Hamed Asghari Date: Fri, 5 Jan 2024 11:32:29 -0700 Subject: [PATCH] Fix email validator strict mode --- lib/clearance/user.rb | 2 +- spec/models/user_spec.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/clearance/user.rb b/lib/clearance/user.rb index 68512bf2..7597452f 100644 --- a/lib/clearance/user.rb +++ b/lib/clearance/user.rb @@ -150,7 +150,7 @@ module Validations included do validates :email, - email: { strict_mode: true }, + email: { mode: :strict }, presence: true, uniqueness: { allow_blank: true, case_sensitive: true }, unless: :email_optional? diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index d9adc323..1b301ecb 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -5,15 +5,15 @@ it { is_expected.to have_db_index(:remember_token) } it { is_expected.to validate_presence_of(:email) } it { is_expected.to validate_presence_of(:password) } - it { is_expected.to allow_value("foo;@example.com").for(:email) } - it { is_expected.to allow_value("foo@.example.com").for(:email) } - it { is_expected.to allow_value("foo@example..com").for(:email) } it { is_expected.to allow_value("foo@example.co.uk").for(:email) } it { is_expected.to allow_value("foo@example.com").for(:email) } it { is_expected.to allow_value("foo+bar@example.com").for(:email) } it { is_expected.not_to allow_value("example.com").for(:email) } it { is_expected.not_to allow_value("foo").for(:email) } it { is_expected.not_to allow_value("foo@").for(:email) } + it { is_expected.not_to allow_value("foo;@example.com").for(:email) } + it { is_expected.not_to allow_value("foo@.example.com").for(:email) } + it { is_expected.not_to allow_value("foo@example..com").for(:email) } describe "#email" do it "stores email in down case and removes whitespace" do