I am doing some very very basic unit testing. If I take away the uniqueness validation, the tests pass. Could this be a bug in Edge Rails?
on 2007-05-28 09:04
on 2007-05-28 09:20
Hi, could you post the test? Thanks, -Conrad
on 2007-05-28 09:36
In my model: validates_uniqueness_of :number, :scope => :school_id Unit test: def test_student_CRUD student = Student.new :school_id => @john.school_id, :number => @john.number assert student.save student_copy = Student.find(student.id) assert_equal student.number, student_copy.number student.number = "7777" assert student.save assert student.destroy end Fixture: john_doe: id: 1 school_id: 1 account_id: 1 family_id: NULL first_name: John last_name: Doe number: 9999 Thanks for any help!
on 2007-05-29 02:48
So what actually happens when you run this test, and what are you expecting it to do? My reading says that it should fail on the first student.save line. (And the test will, of course, pass if you remove the uniqueness validation.)
on 2007-05-29 03:39
You are correct, it fails on the on the save. If I remove it, it does pass. I want it to pass with the validation.
on 2007-05-29 20:11
Why does it fail on the student.save line? the number is unique as there are no other student fixtures.