diff options
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/resources_test.rb | 2 | ||||
-rw-r--r-- | actionpack/test/controller/routing_test.rb | 44 |
2 files changed, 44 insertions, 2 deletions
diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb index 1f61377ad9..979008f21b 100644 --- a/actionpack/test/controller/resources_test.rb +++ b/actionpack/test/controller/resources_test.rb @@ -427,7 +427,7 @@ class ResourcesTest < Test::Unit::TestCase assert_simply_restful_for :products, :controller => "backoffice/products" end end - + protected def with_restful_routing(*args) with_routing do |set| diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 0197bf10e2..2abccd7402 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -1691,7 +1691,7 @@ class RouteSetTest < Test::Unit::TestCase url = set.generate(:controller => "people", :action => "list") assert_equal "/people/list", url end - + def test_root_map Object.const_set(:PeopleController, Class.new) @@ -1705,6 +1705,48 @@ class RouteSetTest < Test::Unit::TestCase ensure Object.send(:remove_const, :PeopleController) end + + + def test_namespace + Object.const_set(:Api, Module.new { |m| m.const_set(:ProductsController, Class.new) }) + + set.draw do |map| + + map.namespace 'api' do |api| + api.route 'inventory', :controller => "products", :action => 'inventory' + end + + end + + request.path = "/api/inventory" + request.method = :get + assert_nothing_raised { set.recognize(request) } + assert_equal("api/products", request.path_parameters[:controller]) + assert_equal("inventory", request.path_parameters[:action]) + ensure + Object.send(:remove_const, :Api) + end + + + def test_namespaced_root_map + Object.const_set(:Api, Module.new { |m| m.const_set(:ProductsController, Class.new) }) + + set.draw do |map| + + map.namespace 'api' do |api| + api.root :controller => "products" + end + + end + + request.path = "/api" + request.method = :get + assert_nothing_raised { set.recognize(request) } + assert_equal("api/products", request.path_parameters[:controller]) + assert_equal("index", request.path_parameters[:action]) + ensure + Object.send(:remove_const, :Api) + end def test_generate_finds_best_fit set.draw do |map| |