From e948a5e2c5131dce5c5e11d7362a523259c83f0b Mon Sep 17 00:00:00 2001 From: Raushan Kumar Raman Date: Tue, 31 Dec 2024 00:34:24 +0530 Subject: [PATCH] feature(user): improved email already taken message for more clarity message --- app/validators/user_validator.rb | 2 +- spec/models/user_spec.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/validators/user_validator.rb b/app/validators/user_validator.rb index 71ae396bef..e5e212fa26 100644 --- a/app/validators/user_validator.rb +++ b/app/validators/user_validator.rb @@ -54,7 +54,7 @@ def validate_date_of_birth_not_before_1920(date_of_birth, record) def validate_email_unique(record) if User.exists?(email: record.email) - record.errors.add(:base, I18n.t('activerecord.errors.messages.email_uniqueness')) + record.errors.add(:base, I18n.t("activerecord.errors.messages.email_uniqueness")) end end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 5bbc2ae39d..c0563d6165 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -55,11 +55,11 @@ expect(user.errors[:base]).to eq([" Date of birth must be on or after 1/1/1920."]) end - it 'shows custom email uniqueness error message' do + it "shows custom email uniqueness error message" do create(:user, email: "volunteer1@example.com") - user = build(:user, email: 'volunteer1@example.com') + user = build(:user, email: "volunteer1@example.com") expect(user.valid?).to be false - expect(user.errors[:base]).to eq ([I18n.t('activerecord.errors.messages.email_uniqueness')]) + expect(user.errors[:base]).to eq([I18n.t("activerecord.errors.messages.email_uniqueness")]) end it "has an empty old_emails array when initialized" do