On Tue, Jul 7, 2009 at 8:06 AM, p_W<[email protected]> wrote: > > I have been developing with RoR for a little but haven't really dived > too much into the testing framework yet ( I know, sacrilege!) . I was > wondering about the best way to test a has_many relationship. Let's > say I have an album that contains many photos. The album model > has_many :photos while the photo model belongs_to :album. I have the > album unit test working but was interested in a way to test that the > relationship will work how I want it to. Should I put that code in > the album unit test? In the functional test? Or in one of the Photo > tests?
While testing your models, you do not have to test Rails's functionality. If there is nothing else in the model apart from has_many and belongs_to statements, you can safely ignore unit testing those models entirely. However, if you have validations and custom methods on the model, you would have to test the functionality of that method in your unit tests. -- Regards, Vagmi Mudumbai ---------------------------- CTO & Co Founder Artha42 Technology Solutions Pvt. Ltd., http://www.artha42.com --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

