diff options
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/action_pack_assertions_test.rb | 22 | ||||
-rw-r--r-- | actionpack/test/controller/routing_test.rb | 12 |
2 files changed, 34 insertions, 0 deletions
diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb index 56b1752392..38aee0077d 100644 --- a/actionpack/test/controller/action_pack_assertions_test.rb +++ b/actionpack/test/controller/action_pack_assertions_test.rb @@ -124,9 +124,18 @@ end module Admin class InnerModuleController < ActionController::Base + def index + render :nothing => true + end + + def redirect_to_index + redirect_to admin_inner_module_path + end + def redirect_to_absolute_controller redirect_to :controller => '/content' end + def redirect_to_fellow_controller redirect_to :controller => 'user' end @@ -267,6 +276,19 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase end end + def test_assert_redirect_to_nested_named_route + with_routing do |set| + set.draw do |map| + map.admin_inner_module 'admin/inner_module', :controller => 'admin/inner_module', :action => 'index' + map.connect ':controller/:action/:id' + end + @controller = Admin::InnerModuleController.new + process :redirect_to_index + # redirection is <{"action"=>"index", "controller"=>"admin/admin/inner_module"}> + assert_redirected_to admin_inner_module_path + end + end + # test the flash-based assertions with something is in the flash def test_flash_assertions_full process :flash_me diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 8def5556b2..93eded194e 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -134,6 +134,13 @@ class LegacyRouteSetTests < Test::Unit::TestCase end + def test_named_route_with_nested_controller + rs.add_named_route :users, 'admin/user', :controller => '/admin/user', :action => 'index' + x = setup_for_named_route.new + assert_equal({:controller => '/admin/user', :action => 'index', :use_route => :users}, + x.send(:users_url)) + end + def setup_for_named_route x = Class.new x.send(:define_method, :url_for) {|x| x} @@ -1177,6 +1184,7 @@ class RouteSetTest < Test::Unit::TestCase map.show '/people/:id', :controller => 'people', :action => 'show' map.index '/people', :controller => 'people', :action => 'index' map.multi '/people/go/:foo/:bar/joe/:id', :controller => 'people', :action => 'multi' + map.users '/admin/users', :controller => 'admin/users', :action => 'index' end klass = Class.new(MockController) @@ -1209,6 +1217,10 @@ class RouteSetTest < Test::Unit::TestCase assert_equal "http://named.route.test/people", controller.send(:index_url) assert_equal "/people", controller.send(:index_path) + + assert_equal "http://named.route.test/admin/users", controller.send(:users_url) + assert_equal '/admin/users', controller.send(:users_path) + assert_equal '/admin/users', set.generate(controller.send(:hash_for_users_url), {:controller => 'users', :action => 'index'}) end def test_namd_route_url_method_with_ordered_parameters |