aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/testing/integration.rb
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2012-06-01 15:53:52 +0200
committerPiotr Sarnacki <drogus@gmail.com>2012-06-01 16:28:43 +0200
commit8d4f63a1a593928c1718e73043c8ca525440fb6b (patch)
tree7ed73a37da25064cfeca99e715e8db15c6defb7c /actionpack/lib/action_dispatch/testing/integration.rb
parentecd1722235d01f44f3fcef032145425cec92d9df (diff)
downloadrails-8d4f63a1a593928c1718e73043c8ca525440fb6b.tar.gz
rails-8d4f63a1a593928c1718e73043c8ca525440fb6b.tar.bz2
rails-8d4f63a1a593928c1718e73043c8ca525440fb6b.zip
Include routes.mounted_helpers into integration tests
In integration tests, you might want to use helpers from engines that you mounted in your application. It's not hard to add it by yourself, but it's unneeded boilerplate. mounted_helpers are now included by default. That means that given engine mounted like: mount Foo::Engine => "/foo", :as => "foo" you will be able to use paths from this engine in tests this way: foo.root_path #=> "/foo" (closes #6573)
Diffstat (limited to 'actionpack/lib/action_dispatch/testing/integration.rb')
-rw-r--r--actionpack/lib/action_dispatch/testing/integration.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb
index ad78854471..ac784b3b60 100644
--- a/actionpack/lib/action_dispatch/testing/integration.rb
+++ b/actionpack/lib/action_dispatch/testing/integration.rb
@@ -177,8 +177,11 @@ module ActionDispatch
# If the app is a Rails app, make url_helpers available on the session
# This makes app.url_for and app.foo_path available in the console
- if app.respond_to?(:routes) && app.routes.respond_to?(:url_helpers)
- singleton_class.class_eval { include app.routes.url_helpers }
+ if app.respond_to?(:routes)
+ singleton_class.class_eval do
+ include app.routes.url_helpers if app.routes.respond_to?(:url_helpers)
+ include app.routes.mounted_helpers if app.routes.respond_to?(:mounted_helpers)
+ end
end
reset!