From aa6637d140c2ebd28bbd23fc250af033a065dbe8 Mon Sep 17 00:00:00 2001 From: Godfrey Chan Date: Mon, 10 Nov 2014 00:30:08 -0800 Subject: Pass the route name explicitly Follow up to 212057b9. Since that commit, we need to pass the `route_name` explicitly. This is one of the left-over cases that was not handled in that commit, which was causing `use_route` to be ignored in functional tests. --- actionpack/test/controller/test_case_test.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'actionpack/test/controller/test_case_test.rb') diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb index 9d7abd5e94..957c0a5288 100644 --- a/actionpack/test/controller/test_case_test.rb +++ b/actionpack/test/controller/test_case_test.rb @@ -499,6 +499,18 @@ XML end end + def test_use_route + with_routing do |set| + set.draw do + get 'via_unnamed_route', to: 'test_case_test/test#test_uri' + get 'via_named_route', as: :a_named_route, to: 'test_case_test/test#test_uri' + end + + get :test_uri, use_route: :a_named_route + assert_equal '/via_named_route', @response.body + end + end + def test_assert_realistic_path_parameters get :test_params, :id => 20, :foo => Object.new -- cgit v1.2.3 From 1b9e85dbbd7d974143e67affb3166d7244cc99db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 18 Nov 2014 18:47:22 -0200 Subject: Make sure assert_select can assert body tag This reverts commit f93df52845766216f0fe36a4586f8abad505cac4, reversing changes made to a455e3f4e9dbfb9630d47878e1239bc424fb7d13. Conflicts: actionpack/lib/action_controller/test_case.rb actionview/lib/action_view/test_case.rb --- actionpack/test/controller/test_case_test.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'actionpack/test/controller/test_case_test.rb') diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb index 957c0a5288..475af90032 100644 --- a/actionpack/test/controller/test_case_test.rb +++ b/actionpack/test/controller/test_case_test.rb @@ -132,6 +132,14 @@ XML render :nothing => true end + def test_without_body + render html: '
'.html_safe + end + + def test_with_body + render html: ''.html_safe + end + private def generate_url(opts) @@ -179,6 +187,19 @@ XML end end + def test_assert_select_without_body + get :test_without_body + + assert_select 'body', 0 + assert_select 'div.foo' + end + + def test_assert_select_with_body + get :test_with_body + + assert_select 'body.foo' + end + def test_url_options_reset @controller = DefaultUrlOptionsCachingController.new get :test_url_options_reset -- cgit v1.2.3 From 77a276411e717353bc562c04d62e144f4410e706 Mon Sep 17 00:00:00 2001 From: Godfrey Chan Date: Sun, 23 Nov 2014 00:07:30 -0800 Subject: Test using `ActionController::TestCase` with engines Reference #17453 [Godfrey Chan, Washington Luiz] --- actionpack/test/controller/test_case_test.rb | 52 ++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'actionpack/test/controller/test_case_test.rb') 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") -- cgit v1.2.3 From 8e73abbda8d3a55459bac728530606fdf69468f5 Mon Sep 17 00:00:00 2001 From: Godfrey Chan Date: Sun, 23 Nov 2014 01:39:17 -0800 Subject: Deprecate `use_route` in controller tests Reference #17453 --- actionpack/test/controller/test_case_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionpack/test/controller/test_case_test.rb') diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb index fdabad3abd..ba2ff7d12c 100644 --- a/actionpack/test/controller/test_case_test.rb +++ b/actionpack/test/controller/test_case_test.rb @@ -528,7 +528,7 @@ XML get 'via_named_route', as: :a_named_route, to: 'test_case_test/test#test_uri' end - get :test_uri, use_route: :a_named_route + assert_deprecated { get :test_uri, use_route: :a_named_route } assert_equal '/via_named_route', @response.body end end @@ -798,7 +798,7 @@ module EngineControllerTests with_routing do |set| set.draw { mount Engine => '/foo' } - get :index, use_route: :foo + assert_deprecated { get :index, use_route: :foo } assert_equal @response.body, 'bar' end end -- cgit v1.2.3