I found a fun gotcha! today with CruiseControl - if you create a custom cruise task you have to set the RAILS_ENV AND ENV["RAILS_ENV"] to test.
If you do not, CruiseControl will run against your production database. Before CruiseControl invokes it's own built-in cruise task it sets the RAILS_ENV to "test", but several lines before that is where it checks for and runs your cruise task, if you define it.
I'm not sure why they don't set the environment before this, but they don't - so be careful!
This is from the CruiseControl manual:
WARNING: with Rails projects, it is important that RAILS_ENV does not default to ‘production’. Unless you want your migration scripts and unit tests to hit your production database, of course. CruiseControl.reb leaves this variable unchanged when invoking ‘cruise’ or other custom Rake task, and sets it to ‘test’ before invoking the defaults.
Fortunately the fix is easy, just make sure you set RAILS_ENV = ENV['RAILS_ENV'] = 'test' in your task.












