This project is archived and is in readonly mode.

#6098 verified
Brian Underwood

ActiveRecord Fixture class

Reported by Brian Underwood | December 1st, 2010 @ 03:48 PM | in 3.1

This is more of a question for the moment.

I'm working on a large Rails app which, unfortunately, has a Fixture model. I'm running into issues where the Fixture class (used for test fixtures) is extending our Fixture model class and causing issue with testing our Fixture model (we've long neglected testing and are just now building up our suite).

I took a look at the ActiveRecord source and the Fixture class seems to be relatively limited in it's usage. It would be much less work to namespace the Fixture class in ActiveRecord than to change all of the various references to the Fixture model in our app (and it would allow other Rails users to have 'Fixture' models). I'd be happy to work on a patch to do this, but I wanted to get advice first and make sure that it would be a good way to go. Should I namespace it in the ActiveRecord module? Should I namespace all of the classes in the fixtures.rb file?

Comments and changes to this ticket

  • Prem Sichanugrist (sikachu)

    Prem Sichanugrist (sikachu) December 9th, 2010 @ 02:32 PM

    • State changed from “new” to “open”
    • Assigned user set to “Prem Sichanugrist (sikachu)”
    • Importance changed from “” to “Medium”

    Yes, I'm agree on having Fixture model namespaced under ActiveRecord module. Would you please provide a patch for it?

    Thank you

  • Brian Underwood

    Brian Underwood December 9th, 2010 @ 08:49 PM

    Thanks! Here's my patch. Since no functionality change I didn't write any tests, but I ran the sqlite3 tests and they all continued to pass? Should I run any others? I also took the changes to the two non-test related files (fixtures.rb and databases.rake) and put them into my install RVM copy of ActiveRecord 3.0.3 and my tests are running now, so that's exciting ;). Let me know if there's anything else that I need to do.

  • Piotr Sarnacki

    Piotr Sarnacki December 10th, 2010 @ 08:20 AM

    It's morning here, so maybe my senses are not so sharp, but how Fixture model could possibly conflict with Fixtures (notice the plural form ;)

  • Brian Underwood

    Brian Underwood December 10th, 2010 @ 01:56 PM

    The issue isn't that the Fixture class conflicts with the Fixtures class (note 'class', not 'model'). The issue is that I have a Rails application (and other people may as well) with a Fixture model which is conflicting with the Fixture class and which is preventing me from running tests on that Fixture model. The Fixtures class was namespaced because it didn't seem right to namespace one and not the other ;)

  • Piotr Sarnacki

    Piotr Sarnacki December 10th, 2010 @ 02:07 PM

    Brian: that means that I should check lighthouse in the evening rather than in the morning. I thought that there is only Fixtures class in rails (I've started testing after factories revolution, so I've never had to do much with it ;).

    So +1 on that from me, looks fine.

  • Brian Underwood

    Brian Underwood December 13th, 2010 @ 03:51 PM

    Just wanted to check to see what's next to move the ticket forward. ;)

  • Brian Underwood

    Brian Underwood December 13th, 2010 @ 06:59 PM

    I actually just noticed that there were some references to the Fixtures class in other parts of Rails than ActiveRecord, so I've made a new patch. I also ran the tests for all of Rails (that took a while :) and all of the tests seem to pass except for two which also seem to be failing in master.

  • Brian Underwood

    Brian Underwood December 15th, 2010 @ 08:15 PM

    Hey, just checking in again. Could somebody let me know what's next for this ticket? Thanks!

  • Prem Sichanugrist (sikachu)

    Prem Sichanugrist (sikachu) December 16th, 2010 @ 04:21 PM

    • Milestone cleared.
    • State changed from “open” to “verified”
    • Assigned user changed from “Prem Sichanugrist (sikachu)” to “Aaron Patterson”

    Your patch looks great! I'll assign to Aaron to get your patch in.

    Aaron, could you please handle this for me? I don't know that it would break any gem/plugin or not if we're pushing it to 3.0.4. I'll leave it to your consideration if we need to put it in CHANGELOG or something.

    Thank you.

  • Piotr Sarnacki

    Piotr Sarnacki December 16th, 2010 @ 05:51 PM

    I would not push it to 3.0.4, it's not a bug, just name collision, it should not be included in patch release, especially because it can break any gem/plugin that uses Fixture class.

  • Brian Underwood

    Brian Underwood December 17th, 2010 @ 12:59 AM

    That's sad, but I can understand that we don't want to break plugins in a patch release. Does that mean it would go into 3.1? We're probably a ways away from a 3.1 upgrade if the Arel syntax is the required ActiveRecord API. We can patch our Rails 3.0.x gems in our dev/test environments, which is a pain, but way less of a pain than refactoring the Fixture model out of our app ;)

  • Aaron Patterson

    Aaron Patterson January 14th, 2011 @ 06:48 PM

    • Milestone set to 3.1

    Can you rebase this patch off master and I'll apply it for 3.1

  • Brian Underwood

    Brian Underwood January 14th, 2011 @ 07:13 PM

    Sure, rebased my branch and created a new patch with a couple of fixes

  • Brian Underwood
  • Brian Underwood

    Brian Underwood April 7th, 2011 @ 04:10 PM

    Poking this ticket since it's been open for a while and it will probably be harder to apply the patch later. Aaron, could you take a look at this? If you can't apply the patch, I can make it again off of the latest 3.1

  • Jason Roth
  • Jason Noble

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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages