diff options
author | Tobias Lütke <tobias.luetke@gmail.com> | 2007-05-19 16:26:44 +0000 |
---|---|---|
committer | Tobias Lütke <tobias.luetke@gmail.com> | 2007-05-19 16:26:44 +0000 |
commit | 10085359058f8b04a061eed1d2c1e44971ae4303 (patch) | |
tree | a23d7b506dcdf4d5d354de0a8410581c7b7b0afe /actionpack/test/controller | |
parent | a995b9cde074bec46ab4befc53f16ff91ec952f2 (diff) | |
download | rails-10085359058f8b04a061eed1d2c1e44971ae4303.tar.gz rails-10085359058f8b04a061eed1d2c1e44971ae4303.tar.bz2 rails-10085359058f8b04a061eed1d2c1e44971ae4303.zip |
Allow routes to be declared off namespaces
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6783 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller')
-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| |