diff options
author | Tarmo Tänav <tarmo@itech.ee> | 2008-07-03 17:49:12 +0300 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-07-03 16:11:50 +0100 |
commit | a37d065f85941e1fe746dff4d42f015e1618834f (patch) | |
tree | 2e498068f1ec02c083150c2471243c5114bf3b1d /actionpack/test | |
parent | d20e8dd2207a848e2712c19ad38d6abb6f98ca07 (diff) | |
download | rails-a37d065f85941e1fe746dff4d42f015e1618834f.tar.gz rails-a37d065f85941e1fe746dff4d42f015e1618834f.tar.bz2 rails-a37d065f85941e1fe746dff4d42f015e1618834f.zip |
Use :namespace instead of :path_prefix for finding controller. [#544 state:resolved]
:namespace is supposed to be the module where controller exists.
:path_prefix can contain anything, including variables, which
makes it unsuitable for determining the module for a controller.
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/routing_test.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 07c13ebbf7..c5ccb71582 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -2039,6 +2039,26 @@ uses_mocha 'LegacyRouteSet, Route, RouteSet and RouteLoading' do Object.send(:remove_const, :Api) end + def test_namespace_with_path_prefix + Object.const_set(:Api, Module.new { |m| m.const_set(:ProductsController, Class.new) }) + + set.draw do |map| + + map.namespace 'api', :path_prefix => 'prefix' do |api| + api.route 'inventory', :controller => "products", :action => 'inventory' + end + + end + + request.path = "/prefix/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_generate_finds_best_fit set.draw do |map| map.connect "/people", :controller => "people", :action => "index" |