Ruby Forum Rails Engines > Tests fail when overwriting models

Posted by Alex Kroman (Guest)
on 19.09.2007 02:51
(Received via mailing list)
Hi all,

I just converted one of our internal applications to use engines and am
really impressed so far.  I'm hoping you can help me clear up a bit of a
problem I am having.

I set up a new application using the engine and everything works great.

The client requests that the user registration page collect the user's
birthday.  I write a test, create a migration, overwrite the user model
to validate_presence_of :birth_date and everything works perfectly.

Unfortunately when I run rake:test:plugins I get a bunch of test
failures because the model is looking for birth_date.  Is there a way to
test your engine without loading up all of the things you are
overwriting in the app directory?

Thanks,
Alex
Posted by James Adam (Guest)
on 24.09.2007 11:32
(Received via mailing list)
In general, you can set

  Engines.disabled_application_code_loading = true

to disable the code mixing features when you want to test your bare
plugin controllers, etc. However, since the code mixing doesn't work
(at the moment) with models, this probably wont help.

The reason why your models are being loaded is simply because
app/models is in the load path, so in your specific case, you might be
able to get around it by removing that path from $LOAD_PATH.

You could also add a Rakefile to your plugin which you can use to run
the tests for your plugin without going through Rails - this would
also isolate your code from anything in app.

HTH,

James