I've been bugged recently by the way table names are resolved for test fixtures.
A side-effect of the current method is that you have to name all of
your fixture accessors after the table, rather than after the class
name.
This means that things get a little less obvious for people using
set_table_name, or Single Table Inheritance.

For example, if I have AddressItem < Item and Item <
ActiveRecord::Base, I have to use "fixtures :items" instead of
"fixtures :address_items", and merge all my STI fixtures into one
file.
I noticed this patch today:
http://dev.rubyonrails.org/ticket/4095
..and was inspired to do something about it.

The attached patch works nicely with my unit tests, and doesn't seem
to break anything.. but I'd appreciate if people using various
platforms could give it a shot.
Also, does this approach look like something appropriate for the core?
 I've seen a number of people ask about this on the Rails list, and go
unanswered.  If so, I'll make a ticket for it.

Thanks,
--Wilson.

Attachment: sti_compatible_fixtures.patch
Description: Binary data

_______________________________________________
Rails-core mailing list
Rails-core@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-core

Reply via email to