25 October, 2005

Testing in Rails

Go to $RAILS_APP_ROOT/test/test_helper.rb and add the following line:

ActiveRecord::Base.connection.update('SET FOREIGN_KEY_CHECKS = 0')

This switches off foreign key constraints (on MySQL anyway) meaning that your tests can load and reload fixtures to their heart's content, without getting hung up on the order of inserts and deletes.

No comments:

Archive

eXTReMe Tracker