For testing, I use:
self.use_transactional_fixtures = true
This should cause a ROLLBACK for each test case. If I run a single file, foo_controller_test.rb, it works as expected. I see BEGIN and ROLLBACK 8 times in the log files. But if I run:
rake test:functionals
I get 3 COMMITs, 196 BEGINS and 193 ROLLBACKs. The code in fixtures.rb that deals with this is :
def teardown_with_fixtures return unless defined?(ActiveRecord::Base) && ! ActiveRecord::Base.configurations.blank? # Rollback changes if a transaction is active. if use_transactional_fixtures? && Thread.current['open_transactions'] != 0 ActiveRecord::Base.connection.rollback_db_transaction Thread.current['open_transactions'] = 0 end ActiveRecord::Base.verify_active_connections! end
and I found that Thread.current['open_transactions'] equals zero in these cases.
anyone else encounter this or see something I'm missing? I guess I'll need to try to follow the increment/decrement of open_transactions.