aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
authorGodfrey Chan <godfreykfc@gmail.com>2014-11-23 00:07:30 -0800
committerGodfrey Chan <godfreykfc@gmail.com>2014-11-23 00:07:30 -0800
commit77a276411e717353bc562c04d62e144f4410e706 (patch)
tree4e5e0aad63fa4504f93e3a4ff4aa48b41aed3c67 /actionpack/test/controller
parentede97c6bb55049b31d6f5114cecd4d5105b80577 (diff)
downloadrails-77a276411e717353bc562c04d62e144f4410e706.tar.gz
rails-77a276411e717353bc562c04d62e144f4410e706.tar.bz2
rails-77a276411e717353bc562c04d62e144f4410e706.zip
Test using `ActionController::TestCase` with engines
Reference #17453 [Godfrey Chan, Washington Luiz]
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/test_case_test.rb52
1 files changed, 52 insertions, 0 deletions
diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb
index 475af90032..fdabad3abd 100644
--- a/actionpack/test/controller/test_case_test.rb
+++ b/actionpack/test/controller/test_case_test.rb
@@ -1,6 +1,7 @@
require 'abstract_unit'
require 'controller/fake_controllers'
require 'active_support/json/decoding'
+require 'rails/engine'
class TestCaseTest < ActionController::TestCase
class TestController < ActionController::Base
@@ -753,6 +754,57 @@ XML
end
end
+module EngineControllerTests
+ class Engine < ::Rails::Engine
+ isolate_namespace EngineControllerTests
+
+ routes.draw do
+ get '/' => 'bar#index'
+ end
+ end
+
+ class BarController < ActionController::Base
+ def index
+ render :text => 'bar'
+ end
+ end
+
+ class BarControllerTest < ActionController::TestCase
+ tests BarController
+
+ def test_engine_controller_route
+ get :index
+ assert_equal @response.body, 'bar'
+ end
+ end
+
+ class BarControllerTestWithExplicitRouteSet < ActionController::TestCase
+ tests BarController
+
+ def setup
+ @routes = Engine.routes
+ end
+
+ def test_engine_controller_route
+ get :index
+ assert_equal @response.body, 'bar'
+ end
+ end
+
+ class BarControllerTestWithHostApplicationRouteSet < ActionController::TestCase
+ tests BarController
+
+ def test_use_route
+ with_routing do |set|
+ set.draw { mount Engine => '/foo' }
+
+ get :index, use_route: :foo
+ assert_equal @response.body, 'bar'
+ end
+ end
+ end
+end
+
class InferringClassNameTest < ActionController::TestCase
def test_determine_controller_class
assert_equal ContentController, determine_class("ContentControllerTest")