# \[Engine Testing\] Dependency issue with ApplicationController

**URL:** <https://www.ruby-forum.com/t/engine-testing-dependency-issue-with-applicationcontroller/87491>\
**Category:** Engines Development\
**Created:** [March 3, 2007, 12:09am UTC](https://www.ruby-forum.com/t/engine-testing-dependency-issue-with-applicationcontroller/87491 "2007-03-03T00:09:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xmg-eric](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/f04885/32.png) [@xmg-eric](https://www.ruby-forum.com/u/xmg-eric)\
**Post date:** [March 3, 2007, 12:09am UTC](https://www.ruby-forum.com/t/engine-testing-dependency-issue-with-applicationcontroller/87491/1 "2007-03-03T00:09:49Z")

</div>

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  
plugin.

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  
end

1. Running this program seems to work fine

2. 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** ),  
‘/…/…/…/…/test/test\_helper’))

as suggested by the documentation.

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

2. When loading the “engine” plugin is loading it requires the testing  
extensions.

3. The testing extensions require ‘test\_help’ provided by Rails.

4. ‘test\_help’ in requires ‘application’. This loads my  
ApplicationController class.

5. 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.

Workarounds:

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.

---

<div class="post-metadata">

**Author:** ![xmg-eric](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/f04885/32.png) [@xmg-eric](https://www.ruby-forum.com/u/xmg-eric)\
**Post date:** [September 25, 2007, 11:10pm UTC](https://www.ruby-forum.com/t/engine-testing-dependency-issue-with-applicationcontroller/87491/2 "2007-09-25T23:10:30Z")

</div>

Tom W. recently committed this change to the 1.2 release branch,  
which can be grabbed from

[http://svn.rails-engines.org/engines/branches/rb\_1.2](http://svn.rails-engines.org/engines/branches/rb_1.2)

… which means it’ll be in the next release.

Cheers,

James

---

<div class="post-metadata">

**Author:** ![xmg-eric](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/f04885/32.png) [@xmg-eric](https://www.ruby-forum.com/u/xmg-eric)\
**Post date:** [September 25, 2007, 11:12pm UTC](https://www.ruby-forum.com/t/engine-testing-dependency-issue-with-applicationcontroller/87491/3 "2007-09-25T23:12:03Z")

</div>

Excellent! Thanks Tom!
