Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11056 (closed defect: fixed)

Opened 5 months ago

Last modified 4 months ago

[PATCH] fixtures should not silently swallow subdependency load errors

Reported by: stuthulhu Assigned to: core
Priority: normal Milestone: 2.x
Component: ActiveRecord Version: edge
Severity: normal Keywords: dependencies troubleshooting verified
Cc:

Description

If you are outside fixtures, then LoadErrors are meaningful, e.g. in script/console

>> AccountController
MissingSourceFile: no such file to load -- hpricot_scan

The same issue blows up cryptically in fixtures, e.g.

LoadError: Expected account_controller.rb to define AccountController

The problem is that fixture loading swallows LoadErrors in silence. The comments seem to indicate that this behavior is necessary in some circumstances. As a band-aid, I have written a patch that at least logs the error.

If somebody has better understanding of when swallowing LoadErrors is appropriate, this patch could be improved to swallow the ok ones and raise the bad ones. I'd be happy to help.

The patch is tested, but the tests are ugly. Better tests would drive a more significant code change, but I didn't want this patch to get caught up in broader issues. If somebody wants to go down this road I will help.

Attachments

load_errors_should_not_be_silent.diff (2.1 kB) - added by stuthulhu on 02/08/08 16:19:19.

Change History

02/08/08 16:19:19 changed by stuthulhu

  • attachment load_errors_should_not_be_silent.diff added.

02/08/08 16:52:46 changed by stuthulhu

  • summary changed from fixtures should not silently swallow subdependency load errors to [PATCH] fixtures should not silently swallow subdependency load errors.

02/15/08 15:10:00 changed by abedra

+1 for the love please add this!

02/15/08 17:03:08 changed by DefV

+1

Great catch!

02/20/08 19:18:00 changed by rsanheim

+1 -- applied to trunk today and worked fine...would be very helpful while dev'ing.

03/17/08 04:34:17 changed by jonathan_viney

Much needed improvement. +1.

03/17/08 04:54:31 changed by thewoolleyman

  • keywords changed from dependencies troubleshooting to dependencies troubleshooting verified.

+1

03/17/08 05:00:12 changed by rsanheim

To further fix this issue across the board, I believe there would need to a similar tweak to Dependencies itself, as I've seen syntax errors get completely swallowed there with no hint as to what the offending line or issue is. This was seen in a test that didn't use fixtures at all, so it was a different code path then the one addressed by this patch.

03/17/08 06:23:10 changed by bitsweat

Please do not +1 if you did not actually verify the patch. That means applying it, testing Rails, and testing your app. Otherwise, three +1 would culminate in 'popular', not 'verified'.

03/17/08 21:48:32 changed by david

  • status changed from new to closed.
  • resolution set to fixed.

(In [9050]) Added logging for dependency load errors with fixtures (closes #11056) [stuthulhu]