Good afternoon Ben,
We’re using database cleaner and we’ve come across some issues trying to use it for our particular situation. We can’t use transaction because it seems it’s not actually inserting the data into the database and as such our app won’t see the data that we try to insert into it via ActiveRecord. Truncation doesn’t quite work for us because it will cause problems if we have tests that access the same table (which we do), or if we attempt to run multiple instances of the same test. To work around this I wrote some code to do a surgical delete. Essentially what it does is keep track of the primary id’s that are being inserted into the DB (currently in an array) and then goes through those arrays and removes all of the records that were inserted into the tables that have id’s in this array. My question is this… Would this be a strategy that we might implement and roll into Database cleaner and if so did you have any pointers and ideas that you might give me in regards to the code of DatabaseCleaner that I might keep in mind as I look through the code? I’m not quite sure if this can even be added into it. A coworker and I are working on generalizing it as best as we can in hopes that it can be self-aware and/or generalized so other people might be able to make use of it. Just thought I’d get any thoughts or ideas that you might have on this.
Thanks,
Brandon