aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorTom Stuart <tom@experthuman.com>2009-03-07 22:50:58 +0000
committerPratik Naik <pratiknaik@gmail.com>2009-03-07 22:50:58 +0000
commit5c87e9adddc22703a3dbbb785e32fafe0e91ce78 (patch)
tree24e1700683cc88c3bdcbee9bd2f3eafd6761c38f /actionpack/test
parent74387884819e8b6e16c3f67388610b8d1192cb4d (diff)
downloadrails-5c87e9adddc22703a3dbbb785e32fafe0e91ce78.tar.gz
rails-5c87e9adddc22703a3dbbb785e32fafe0e91ce78.tar.bz2
rails-5c87e9adddc22703a3dbbb785e32fafe0e91ce78.zip
Ensure shallow routes respects namespace [#1356 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/resources_test.rb34
1 files changed, 31 insertions, 3 deletions
diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb
index fee41362c1..17f6d99b21 100644
--- a/actionpack/test/controller/resources_test.rb
+++ b/actionpack/test/controller/resources_test.rb
@@ -414,6 +414,34 @@ class ResourcesTest < ActionController::TestCase
end
end
+ def test_shallow_nested_restful_routes_with_namespaces
+ with_routing do |set|
+ set.draw do |map|
+ map.namespace :backoffice do |map|
+ map.namespace :admin do |map|
+ map.resources :products, :shallow => true do |map|
+ map.resources :images
+ end
+ end
+ end
+ end
+
+ assert_simply_restful_for :products,
+ :controller => 'backoffice/admin/products',
+ :namespace => 'backoffice/admin/',
+ :name_prefix => 'backoffice_admin_',
+ :path_prefix => 'backoffice/admin/',
+ :shallow => true
+ assert_simply_restful_for :images,
+ :controller => 'backoffice/admin/images',
+ :namespace => 'backoffice/admin/',
+ :name_prefix => 'backoffice_admin_product_',
+ :path_prefix => 'backoffice/admin/products/1/',
+ :shallow => true,
+ :options => { :product_id => '1' }
+ end
+ end
+
def test_restful_routes_dont_generate_duplicates
with_restful_routing :messages do
routes = ActionController::Routing::Routes.routes
@@ -1082,7 +1110,7 @@ class ResourcesTest < ActionController::TestCase
path = "#{options[:as] || controller_name}"
collection_path = "/#{options[:path_prefix]}#{path}"
- shallow_path = "/#{options[:path_prefix] unless options[:shallow]}#{path}"
+ shallow_path = "/#{options[:shallow] ? options[:namespace] : options[:path_prefix]}#{path}"
member_path = "#{shallow_path}/1"
new_path = "#{collection_path}/#{new_action}"
edit_member_path = "#{member_path}/#{edit_action}"
@@ -1146,10 +1174,10 @@ class ResourcesTest < ActionController::TestCase
options[:options].delete :action
path = "#{options[:as] || controller_name}"
- shallow_path = "/#{options[:path_prefix] unless options[:shallow]}#{path}"
+ shallow_path = "/#{options[:shallow] ? options[:namespace] : options[:path_prefix]}#{path}"
full_path = "/#{options[:path_prefix]}#{path}"
name_prefix = options[:name_prefix]
- shallow_prefix = "#{options[:name_prefix] unless options[:shallow]}"
+ shallow_prefix = options[:shallow] ? options[:namespace].try(:gsub, /\//, '_') : options[:name_prefix]
new_action = "new"
edit_action = "edit"