Engines bug breaks functional tests with datetime_toolbocks

This is following up on http://lists.toolbocks.com/pipermail/
toolbocks-user/2007-May/000027.html
(datetime_toolbocks fails in functional tests)

Here’s the problem:

Engines causes plugins to be loaded in 2 phases. First plugins that
don’t depend on engines are loaded. Then Rails does some
initialization. Then Engines patches Rails. Then the remaining
plugins get loaded.

After all that is done, Engines’ modifications of dependencies.rb
will cause a subsequent load of application_helper to be patched by
application_helper files in plugins. All well and good in
development and production mode.

The trouble comes in test mode: the file ~rails/lib/test_help.rb gets
loaded during Rails’s initialization, before the engines plugins.
test_help.rb requires application.rb, which in turn loads
application_helper.rb. Because the engines plugins haven’t been
loaded yet, application_helper.rb is unpatched, and
datetime_toolbocks’s methods are unavailable to functional tests.

It looks like there is a related bug in the engines repository:
http://dev.rails-engines.org/engines-plugin/tickets/16

A nasty fix is to copy ~rails/lib/test_help.rb to your project’s lib
directory and then add the following two lines right before the call
to require_dependency ‘application’

require ‘engines’
Engines.after_initialize

(Engines.after_initialize loads the extra plugins)

Geoff

Hi Geoff,

Thanks for the thorough investigation. The first thing I’d do here
would be to open a new ticket (or reopen Ticket #16) and post your
findings there. Then we can start looking at how to fix this issue in
the test environment.

James