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? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, could you post the test? Thanks, -Conrad On 5/28/07, jko170 <jko170-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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? > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 28/05/2007, at 5:36 PM, jko170 wrote:> > 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! > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Why does it fail on the student.save line? the number is unique as there are no other student fixtures. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Possibly Parallel Threads
- record will absolutely not save! so weird, please help.
- acts_as_list with scope : position update problem?
- When adding a record in console, a parameter comes in as null even when I set it
- Explanation of how Scope works?
- validates_uniqueness_of(*attr_names) w scope not working in unit test