Skip to content

Instantly share code, notes, and snippets.

View charleseff's full-sized avatar

Charles Finkel charleseff

  • San Francisco, CA
View GitHub Profile
@charleseff
charleseff / after_commit_with_transactional_fixtures.rb
Created October 21, 2011 23:45 — forked from dcuddeback/after_commit_with_transactional_fixtures.rb
Patch ActiveRecord to fire after_commit callbacks at the appropriate time during tests with transactional fixtures.
module ActiveRecord
module ConnectionAdapters
module DatabaseStatements
#
# Run the normal transaction method; when it's done, check to see if there
# is exactly one open transaction. If so, that's the transactional
# fixtures transaction; from the model's standpoint, the completed
# transaction is the real deal. Send commit callbacks to models.
#
# If the transaction block raises a Rollback, we need to know, so we don't