Francois Beausoleil
2006-Mar-13 20:30 UTC
[3804] causes FixtureClassNotFound for HABTM join tables
http://dev.rubyonrails.org/changeset/3804 This test case fails in r3804 and later: class CategoriesControllerTest < Test::Unit::TestCase fixtures :categories_screenshots def test_update ... end end 11) Error: test_update_accepts_screenshot(CategoriesControllerTest): FixtureClassNotFound: The class "CategoriesScreenshot" was not found. D:/app/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:401:in `find' D:/app/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:226:in `instantiate_fixtures' D:/app/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:225:in `each' D:/app/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:225:in `instantiate_fixtures' D:/app/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:224:in `silence' D:/app/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:224:in `instantiate_fixtures' D:/app/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:587:in `instantiate_fixtures' D:/app/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:586:in `each' D:/app/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:586:in `instantiate_fixtures' D:/app/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:523:in `setup_with_fixtures' D:/app/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:545:in `setup' D:/app/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:544:in `setup' Note the class name was partially singularized. in r3803, Fixture simply returned a nil object on Fixture#find: http://dev.rubyonrails.org/browser/trunk/activerecord/lib/active_record/fixtures.rb?rev=3803#L393 In r3804, the system is more robust because it raises an exception if the class cannot be found: http://dev.rubyonrails.org/browser/trunk/activerecord/lib/active_record/fixtures.rb?rev=3804#L396 I narrowed the problem down to lines 274-275 of Fixtures: http://dev.rubyonrails.org/browser/trunk/activerecord/lib/active_record/fixtures.rb#L274 categories_screenshots is an habtm join table. There is no class of that name, nor should there be. I am not sure how I should patch my way around this... Any help appreciated. Can Inflector properly singularize such a beast ? Thanks ! -- François Beausoleil http://blog.teksol.info/ _______________________________________________ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core
Rick Olson
2006-Mar-13 20:49 UTC
Re: [3804] causes FixtureClassNotFound for HABTM join tables
On 3/13/06, Francois Beausoleil <francois.beausoleil@gmail.com> wrote:> http://dev.rubyonrails.org/changeset/3804 > > This test case fails in r3804 and later: > > class CategoriesControllerTest < Test::Unit::TestCase > fixtures :categories_screenshots > > def test_update > ... > end > end > > 11) Error: > test_update_accepts_screenshot(CategoriesControllerTest): > FixtureClassNotFound: The class "CategoriesScreenshot" was not found. > D:/app/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:401:in > `find'' > D:/app/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:226:in > `instantiate_fixtures'' > D:/app/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:225:in > `each'' > D:/app/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:225:in > `instantiate_fixtures'' > D:/app/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:224:in > `silence'' > D:/app/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:224:in > `instantiate_fixtures'' > D:/app/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:587:in > `instantiate_fixtures'' > D:/app/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:586:in > `each'' > D:/app/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:586:in > `instantiate_fixtures'' > D:/app/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:523:in > `setup_with_fixtures'' > D:/app/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:545:in > `setup'' > D:/app/config/../vendor/rails/activerecord/lib/active_record/fixtures.rb:544:in > `setup'' > > Note the class name was partially singularized. > > in r3803, Fixture simply returned a nil object on Fixture#find: > http://dev.rubyonrails.org/browser/trunk/activerecord/lib/active_record/fixtures.rb?rev=3803#L393 > > In r3804, the system is more robust because it raises an exception if > the class cannot be found: > http://dev.rubyonrails.org/browser/trunk/activerecord/lib/active_record/fixtures.rb?rev=3804#L396 > > I narrowed the problem down to lines 274-275 of Fixtures: > http://dev.rubyonrails.org/browser/trunk/activerecord/lib/active_record/fixtures.rb#L274 > > categories_screenshots is an habtm join table. There is no class of > that name, nor should there be. > > I am not sure how I should patch my way around this... Any help > appreciated. Can Inflector properly singularize such a beast ? > > Thanks ! > -- > François Beausoleil > http://blog.teksol.info/What are you trying to do? If this is a habtm, there is no join model, so you shouldn''t be calling categories_screenshots(:foo). If it is a join model that''s named differently, then you need to set the proper fixture class: fixtures :categories_screenshots set_fixture_class :categories_screenshots => CategoryScreenshot If I recall, I wrote it so it *only* raises the exception if you try to call categories_screenshots(), which tries to load the model record. -- Rick Olson http://techno-weenie.net
Francois Beausoleil
2006-Mar-13 21:44 UTC
Re: [3804] causes FixtureClassNotFound for HABTM join tables
2006/3/13, Rick Olson <technoweenie@gmail.com>:> What are you trying to do? If this is a habtm, there is no joinLoad the fixtures on setup.> model, so you shouldn't be calling categories_screenshots(:foo). If > it is a join model that's named differently, then you need to set the > proper fixture class: > > fixtures :categories_screenshots > set_fixture_class :categories_screenshots => CategoryScreenshot > > If I recall, I wrote it so it *only* raises the exception if you try > to call categories_screenshots(), which tries to load the model > record.The exception will be raised anytime Fixture#find is called. In my case, it happens during setup because it seems use_instantiated_fixtures is true ?! More on that in another E-Mail. Anyway, I properly configured TestCase, and now everything works with HEAD. Thanks ! -- François Beausoleil http://blog.teksol.info/ _______________________________________________ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core
Rick Olson
2006-Mar-13 23:01 UTC
Re: [3804] causes FixtureClassNotFound for HABTM join tables
> The exception will be raised anytime Fixture#find is called. In my > case, it happens during setup because it seems > use_instantiated_fixtures is true ?! More on that in another E-Mail. > > Anyway, I properly configured TestCase, and now everything works with HEAD. > > Thanks ! > -- > François Beausoleil > http://blog.teksol.info/Hmm, perhaps the part that loads instantiated fixtures should catch that exception then. Thoughts? I''m the one that added the exception, so I''ll fix it :) -- Rick Olson http://techno-weenie.net