Rails 3: ActiveRecord observer: after_commit callback doesn't fire during tests, but after_save does fire
问题 I have a Rails 3 application. I use after_save callbacks for some models and after_commit callbacks for one of the models. All of the code the code works fine, but during RSpec tests, the after_commit callback doesn't get called when I save a Thing model. e.g. class ThingObserver < ActiveRecord:Observer observe Thing def after_commit(thing) puts thing.inspect end end If I change the method name to after_save , it gets called fine during tests. I need to be able to use after_commit for this