Factory Girl Associations Issue with Uniqueness Validations

Greetings,

Does anybody have a workaround/solution for Factory Girl's insistence on creating a new record for each association it creates? As far as I can tell, this makes using Factory Girl unusable when you have uniqueness validations on the model referenced by the FK when testing interrelated has_many/belongs_to associations.

What am I missing here? Google shows many people with same issue without a clear resolution. I may just need some sleep. :slight_smile:

Thanks

TMA

I have exactly the same problem... but no solution. Would also greatly appreciate suggestions as to a workaround.

When I encounter this type of issue, I tend to create the high level objects and then explicitly include them

@author = Factory(:author)

book1 = Factory(:book, :author => @author) book2 = Factory(:book, :author => @author) etc.

Andrew Timberlake http://ramblingsonrails.com http://www.linkedin.com/in/andrewtimberlake

"I have never let my schooling interfere with my education" - Mark Twain