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.



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.



All Articles