Skip to content

Commit

Permalink
feature(user): improved email already taken message for more clarity …
Browse files Browse the repository at this point in the history
…message
  • Loading branch information
Raushan Kumar Raman committed Dec 30, 2024
1 parent bf19085 commit e948a5e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/validators/user_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: "[email protected]")
user = build(:user, email: '[email protected]')
user = build(:user, email: "[email protected]")
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
Expand Down

0 comments on commit e948a5e

Please sign in to comment.