Forum: Ruby on Rails Fixtures and single table inheritance

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D6ad52affc12fb2b49b0e5a215a8410a?d=identicon&s=25 Matt Torok (Guest)
on 2006-03-18 13:34
(Received via mailing list)
I'm wondering what the accepted method for doing unit tests on STI
models is.

I tried to create a fixture for the class but Rails tries to load that
data into the non-existent child table. I could create a fixture named
for the real, parent table, but then it would be very difficult to
test for the individual functionality and integrity of each sub-class.

I saw this page
http://wiki.rubyonrails.com/rails/pages/FlexibleFixtures , but the
comment at the top leads me to believe that solution won't work, and I
would like to avoid using the linked patch to fork my Rails install
since that sounds like more trouble than it's worth.

Unit testing an STI model seems like a fairly com men event, so there
must be some easy way to do it. What am I missing?
--
-Matt Torok
D6ad52affc12fb2b49b0e5a215a8410a?d=identicon&s=25 Matt Torok (Guest)
on 2006-03-19 15:58
(Received via mailing list)
On 3/18/06, Matt Torok <magicmat@gmail.com> wrote:
> would like to avoid using the linked patch to fork my Rails install
> since that sounds like more trouble than it's worth.
>
> Unit testing an STI model seems like a fairly com men event, so there
> must be some easy way to do it. What am I missing?
> --
> -Matt Torok
>

OK, I applied Duane's patch linked to from the above-mentioned wiki
page, but it too doesn't appear to play well with STI, even when I
manually specificy the correct table name. I e-mailed Duane about it
to see if it was a known bug, or something I did wrong. In the
meantime, does anybody have any pointers on how they unit test STI
classes?

Like I said above, this task would seem to be a common one. STI
classes especially would need a good unit testing system. I can't be
the first guy to run into this, so what does everybody else do in this
situation? What obvious thing am I missing?

--
-Matt Torok
This topic is locked and can not be replied to.