This project is archived and is in readonly mode.

#3395 ✓stale
Andrew Selder

Transaction fixtures don't work if model has a different connection than ActiveRecord::Base

Reported by Andrew Selder | October 20th, 2009 @ 05:28 AM

When using transactional fixtures each example is wrapped in a database transactions. This transaction is started on ActiveRecord::Base's connection. However if you use fixture for a model that has a different connection, any changes to this model are not inside of a transaction. This means that changes to this table accumulate and are not reset between examples.

The solution should be fairly simple. Instead of only using database transaction on AR::Base, start a transaction against every connection referred to by a model.

attached is a diff based on Rails 2.2.2 which illustrates the basic idea. I'll create a proper patch against HEAD shortly, as well as write some test.

Comments and changes to this ticket

  • Andrew Selder

    Andrew Selder October 20th, 2009 @ 05:29 AM

    The diff is against fixtures.rb in case it wasn't clear.

  • Rohit Arondekar

    Rohit Arondekar October 6th, 2010 @ 06:37 AM

    • State changed from “new” to “stale”
    • Importance changed from “” to “”

    Marking ticket as stale. If this is still an issue please leave a comment with suggested changes, creating a patch with tests, rebasing an existing patch or just confirming the issue on a latest release or master/branches.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>