In my user.rb model, I have:
validates :email, presence: true,
format: { with: VALID_EMAIL_REGEX },
uniqueness: { case_sensitive: false }
And I have the following test:
test "email address uniqueness regardless of case" do
dup_user = User.new(name: "First Last", email: @user.email.upcase)
dup_user.save
assert !@user.valid?
end
And that test won’t pass. I also tried, assert !@user.save.valid? thinking that it would fail on save, but that didn’t work either.
What am I doing wrong?
You should be checking if the
dup_useris valid.