Take the 2-minute tour ×

i would like to disable use_transactional_fixtures = false in ministest to catch after_commit callback. What and where should i set-up?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

You have a few options. One is to create a test without transactional fixtures and hope that the changes you make to the test database isn't going to break any other tests.

class SomethingTest < ActiveSupport::TestCase
  self.use_transactional_fixtures = false

  def test_something_with_after_commit
    # do work here, which will change your test database

Another option you have is to keep the transactional fixtures, but invoke the after_commit callback manually.

class SomethingTest < ActiveSupport::TestCase
  def test_something_with_after_commit
    something = Something.new
    # verify things happened as expected

And yet another option is to move the logic out of the after_commit callback into a new object, where you can write proper tests for it without relying on the callbacks to be invoked.

share|improve this answer

Your Answer


