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?
Hi, could you post the test?
Thanks,
-Conrad
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!
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.)
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.
Why does it fail on the student.save line? the number is unique as there are no other student fixtures.