Hey The fixtures should satisfy not-null constraints if you specify everything through the generator. If you manipulate the migration directly, your fixtures won't be updated accordingly. I got bitten by this in the past. Especially because the model generator does not generate concrete test-cases making use of these fixtures. When you start writing your own you may end up with ActiveRecord::StatementInvalid errors which can feel out of context.
I'd be fine with commenting out the fixtures when the model generator is used. Note that the scaffold generator does generate test-cases which use the fixtures. Cheers, -- Yves On Monday, November 17, 2014 4:31:40 AM UTC+1, Prathamesh Sonpatki wrote: > > Hi Colin, > > I was suggesting that can we comment them in the generators itself. So > that they will be present but commented. Obviously when we want to write > tests and use them, we have to go to that file and edit it. We have to do > it in any case, whether they are commented or not. > > Thanks. > > On Mon, Nov 17, 2014 at 3:39 AM, Colin Law <cla...@gmail.com <javascript:> > > wrote: > >> On 16 November 2014 14:54, Prathamesh Sonpatki <cson...@gmail.com >> <javascript:>> wrote: >> > Hello all, >> > >> > A newly created fixture file by Rails generators contains some fixtures >> by >> > default with keys 'one' and 'two'. >> > If I add any null constraint on some column in that table and try to run >> > tests then it fails. Because Rails tries >> > to insert records with null values on columns having not-null >> constraint. >> > >> > What do you think about adding the fixtures through generators but >> > commenting them. So when I actually want >> > to use those fixtures, I will go into fixtures file and uncomment the >> > existing ones or add new ones. >> > Right now it becomes a little painful to see build failing just because >> of >> > those fixtures. >> >> Not sure what question you are asking, but to comment them out just >> put # at the front of each line. >> >> Anyway you are writing things the wrong way round, you should add or >> amend the tests to check the constraint functions as expected (which >> will cause the test to fail as the constraint has not been added yet) >> then add the constraint so that the tests work again. >> >> Colin >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Core" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to rubyonrails-co...@googlegroups.com <javascript:>. >> To post to this group, send email to rubyonra...@googlegroups.com >> <javascript:>. >> Visit this group at http://groups.google.com/group/rubyonrails-core. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > ./prathamesh > GITHUB <https://github.com/prathamesh-sonpatki> Blog > <http://prathamesh-sonpatki.github.com> > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.