Factory_girl verification issues

I am using factory_girl to generate users and database_cleaner to clean up the database after tests, but I have validation errors: uniqueness. Here is my spec_helper, custom model and other files that are affected.

https://gist.github.com/2006719

+3


source to share


1 answer


It looks like the User is not dynamically generated every time the page is created. Try changing line 12 in factories to:

f.user_id { Factory(:user).id }

      

or even



f.user { Factory :user }

      

Hope this helps.

+1


source







All Articles