Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

FactoryGirl.lint leaves created objects in database #614

deiga opened this Issue Feb 16, 2014 · 4 comments


None yet
4 participants

deiga commented Feb 16, 2014

It's not good practice for lint to create objects and then leave them in the database, this messes peoples tests up.

A better solution would be to delete the object after validity has been confirmed.

deiga commented Feb 18, 2014

This happens only when the factories reference another builder, which then create the objects, since there is no way to reference objects which are only built :)

Is there any reason why the linting process cannot take place in a transaction by default?

@garysweaver garysweaver added a commit to garysweaver/factory_girl that referenced this issue Feb 20, 2014

@garysweaver garysweaver #614 - added note about using DatabaseCleaner to wrap lint if any fac…
…tory builds persist data

Just encountered this as well. I think I can also confirm that this only happens when models belong_to another model. I believe auto-cleaning should be the expected behavior here.

Maybe the linter could somehow keep track of all of the records it creates and nuke them once done? Not sure how that'd work, though.


joshuaclayton commented Feb 27, 2014

@deiga @tonyd256 @gabrielecirulli I've added 7f31ba9 which should address the concerns. It does introduce a dependency on DatabaseCleaner (which will likely already be present!) and is ORM/ODM agnostic, which I see as a big benefit.

I'll close this for now, but if this doesn't address a concern, we can continue discussing on this thread; thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment