aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/routing_test.rb
diff options
context:
space:
mode:
authorTobias Lütke <tobias.luetke@gmail.com>2007-05-19 16:26:44 +0000
committerTobias Lütke <tobias.luetke@gmail.com>2007-05-19 16:26:44 +0000
commit10085359058f8b04a061eed1d2c1e44971ae4303 (patch)
treea23d7b506dcdf4d5d354de0a8410581c7b7b0afe /actionpack/test/controller/routing_test.rb
parenta995b9cde074bec46ab4befc53f16ff91ec952f2 (diff)
downloadrails-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/routing_test.rb')
-rw-r--r--actionpack/test/controller/routing_test.rb44
1 files changed, 43 insertions, 1 deletions
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|