Forum: Rails Engines development [Engine Testing] Dependency issue with ApplicationController

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Eric A. (Guest)
on 2007-03-03 01:09
(Received via mailing list)
I seem to be having a dependency issue when running my test while
applying a mixin implemented by an engine into my Application
controller. I found a work around but wanted to post the problem, cause
and workarounds in hope that a solution can be put into the Engines

Let me break it down:

1. I define a mix in my engine under lib/my_engine/foo.rb. We'll call
the mixin MyEngine::Foo.

2. I then put the following in my application controller to apply the
mixin to all controllers:

class ApplicationController < ActionController::Base
   include MyEngine::Foo

3. Running this program seems to work fine

4. When I run my testing it cannot seem to find the module MyEngine::Foo

I have traced the problem to the following:

1. My test_helper.rb in my engine has the following for the first line:

require File.expand_path(File.join(File.dirname(__FILE__),

as suggested by the documentation.

2. This requires the environment which of course starts the process of
booting Rails.

3. When loading the "engine" plugin is loading it requires the testing

4. The testing extensions require 'test_help' provided by Rails.

5. 'test_help' in requires 'application'. This loads my
ApplicationController class.

6. My ApplicationController tries to include my mixin but it cannot find
the module because my engine has not initialized yet (since it comes
after the engine plugin alphabetically). Hence leading to my problem.


1. Make the "engines" plugin load after the problem plugin
2. Comment out the "require 'test_help'". It is not necessary anyway
since the test_helper generated by rails requires it later.
James A. (Guest)
on 2007-09-26 01:10
(Received via mailing list)
Tom W. recently committed this change to the 1.2 release branch,
which can be grabbed from

... which means it'll be in the next release.


Michael H. (Guest)
on 2007-09-26 01:12
(Received via mailing list)
Excellent! Thanks Tom!
This topic is locked and can not be replied to.