From 8d4f63a1a593928c1718e73043c8ca525440fb6b Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 1 Jun 2012 15:53:52 +0200 Subject: 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) --- actionpack/test/controller/integration_test.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'actionpack/test/controller/integration_test.rb') diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index fda263310b..a9e59e2dbb 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -495,11 +495,26 @@ class ApplicationIntegrationTest < ActionDispatch::IntegrationTest @routes ||= ActionDispatch::Routing::RouteSet.new end + class MountedApp + def self.routes + @routes ||= ActionDispatch::Routing::RouteSet.new + end + + routes.draw do + match 'baz', :to => 'application_integration_test/test#index', :as => :baz + end + + def self.call(*) + end + end + routes.draw do match '', :to => 'application_integration_test/test#index', :as => :empty_string match 'foo', :to => 'application_integration_test/test#index', :as => :foo match 'bar', :to => 'application_integration_test/test#index', :as => :bar + + mount MountedApp => '/mounted', :as => "mounted" end def app @@ -512,6 +527,10 @@ class ApplicationIntegrationTest < ActionDispatch::IntegrationTest assert_equal '/bar', bar_path end + test "includes mounted helpers" do + assert_equal '/mounted/baz', mounted.baz_path + end + test "route helpers after controller access" do get '/' assert_equal '/', empty_string_path -- cgit v1.2.3