Displaying 1 result from an estimated 1 matches for "valid_person".
2006 Oct 05
0
ActiveRecord Validations - validates_uniqueness_of
...doing a few things like this recently trying to avoid as
many database hits as I can. I still haven''t figured out a great way
to do this for stock validations, but I am making a point of keeping
the database clean, and verifying explicit things. My take on the
above would be like so:
def valid_person(opts={})
Person.new({:email => "a at b.com"}.merge(opts))
end
def test_person_should_validate_uniqueness_of_email
person = valid_person
person.save
assert_false valid_person.valid?
assert_true valid_person(:email => "b at b.com").valid?
person.destroy
end
Hav...