Displaying 1 result from an estimated 1 matches for "valid_foo".
Did you mean:
val_foo
2006 Oct 05
0
ActiveRecord Validations - validates_uniqueness_of
...)
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
Having the valid_foo shortcut helps immensely once you get behond a
handful of validations. As for the test itself, I''m cleaning up the
entry that does make it to the database, and preventing more potential
database hits by just calling valid? instead of save. I suppose I
could be a bit pedantic and create a...