rails/rails — pull request #9588 by LinuxFan2718 (2013-03-06 21:15:32+00:00)
Title: Fix issue #8937 after_commit(on: :update) executed erroneously

We check for a state in the current ActiveRecord
transaction that causes the wrong callbacks to be
executed, and when it occurs, call the correct
callbacks.

Tests lifted from
https://github.com/rails/rails/commit/b42ea033115c1a06160e4092039d6a0fe0bda6f8