cruisecontrol.rb, seed data, and FKs
Custom cruisecontrol.rb task to handle migrations with seed data. (for when standard cruise build task yields FK constraint violations when the fixtures start loading).
#This builds from migrations each time (slower, but more reliable). #Must then empty seed data before tests start to delete stuff, or FK constraints get violated. task :cruise do ENV['RAILS_ENV'] = 'test' puts "custom cruise task invoked. env is hardcoded to test" Rake::Task["environment"].invoke #start from scratch with just the test db Rake::Task["db:test:purge"].invoke #necessary to reconnect, as purge drops database (and w mysql the conn) CruiseControl::reconnect #run all migrations from scratch. slow but clean Rake::Task["db:migrate"].invoke #empty the db of data - migration has loaded seed data into the tables, #which'll be deleted badly by test fixtures loader. #NOTE: db:test:purgetwo is just a quick hack to force this identical action to be called again #TODO: replace with the correct way to force execution of a task in rake Rake::Task["db:test:purgetwo"].invoke #necessary to reconnect, as purge drops database (and w mysql the conn) CruiseControl::reconnect #the migration has already done a schema dump Rake::Task["db:schema:load"].invoke success = Rake::Task["test"].invoke success end
Embarrassingly, this currently needs ‘db:test:purgetwo’ to exist. I just copied pasted db:test:purge task. The correct way would be to look at how to ensure task execution in rake, but debugging cruisecontrol.rb exhausted all my patience and sanity.
See also What ‘rake test’ does.
May 6th, 2010 at 4:40 am
good job,guy,it’s kind of u share this post with us which give useful information to us.God Job!I do hope u can publish more posts later.buy the way ,if you wanna buy cheap brand shoes online,you may visit our shoes store,i am sure you will find what u like.
July 8th, 2010 at 7:38 am
Sorry, but your comment has been flagged by the spam filter running on this blog: this might be an error, in which case all apologies. Your comment will be presented to the blog admin who will be able to restore it immediately.
You may want to contact the blog admin via e-mail to notify him.
July 8th, 2010 at 7:46 am
I do hope u can publish more posts later.b
July 8th, 2010 at 7:47 am
You may want to contact the blog admin via e-mail to notify him.
August 31st, 2010 at 12:00 pm
Very useful information, tks for sharing!