I'm working on a hack to preload fixtures, and decided that test_helper.rb was the best place to do this. I define a method and then call it right away.
In brief, this method runs rake/shell tasks using ´´ (bad approach, I know.. - suggestions?), i.e.:
def preload_fixtures dump my dev db ddl `rake db:test:purge` load the test db with all ddl except FKs `rake db:fixtures:load RAILS_ENV=test` load the FKs end preload_fixtures()
However, step #2 fails, as the purge task for postgres works by dropping and recreating the db, which can't be done while there's an open connection to it.
I've tried calling ActiveRecord::Base.connection.disconnect! right before running the purge task, to no avail. I figure the connection may not even be using AR..
Anyone familiar enough with the workings here to give some advice?
This is all very fragile and platform dependant anyway, so path of
least resistance is preferred, don't worry about cleanliness..
--
The various plugins for specifying fixture load order are _not_ an
option, though.
Thanks in advance, Isak