Rails4 minitest after_commit 没有被触发

Rails4 中存在的 buguse_transactional_fixtures 启用的时候会引发这个 bug

这样设置可以修复,但是测试会更改测试数据库。

class FooTest < ActiveSupport::TestCase
  self.use_transactional_fixtures = false
end

use_transactional_fixtures = true 的含义:

In Rails 4.x we have transactional fixtures that wrap each test in a database transaction. This transaction rollbacks all the changes at the end of the test. It means the state of the database, before the test is same as after the test is done.