mirror of
https://github.com/github/rails.git
synced 2026-01-30 08:48:06 -05:00
Allow nested namespaces in routing
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6748 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -351,7 +351,11 @@ module ActionController
|
||||
# It'll also create admin_product_tags_url pointing to "admin/products/#{product_id}/tags", which will look for
|
||||
# Admin::TagsController.
|
||||
def namespace(name, options = {}, &block)
|
||||
with_options({ :path_prefix => name, :name_prefix => "#{name}_", :namespace => "#{name}/" }.merge(options), &block)
|
||||
if options[:namespace]
|
||||
with_options({:path_prefix => "#{options.delete(:path_prefix)}/#{name}", :name_prefix => "#{options.delete(:name_prefix)}#{name}_", :namespace => "#{options.delete(:namespace)}#{name}/" }.merge(options), &block)
|
||||
else
|
||||
with_options({ :path_prefix => name.to_s, :name_prefix => "#{name}_", :namespace => "#{name}/" }.merge(options), &block)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,10 @@ class AdminController < ResourcesController; end
|
||||
|
||||
module Backoffice
|
||||
class ProductsController < ResourcesController; end
|
||||
|
||||
module Admin
|
||||
class ProductsController < ResourcesController; end
|
||||
end
|
||||
end
|
||||
|
||||
class ResourcesTest < Test::Unit::TestCase
|
||||
@@ -400,6 +404,20 @@ class ResourcesTest < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
def test_resources_in_nested_namespace
|
||||
with_routing do |set|
|
||||
set.draw do |map|
|
||||
map.namespace :backoffice do |backoffice|
|
||||
backoffice.namespace :admin do |admin|
|
||||
admin.resources :products
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
assert_simply_restful_for :products, :controller => "backoffice/admin/products", :name_prefix => 'backoffice_admin_', :path_prefix => 'backoffice/admin/'
|
||||
end
|
||||
end
|
||||
|
||||
def test_resources_using_namespace
|
||||
with_routing do |set|
|
||||
set.draw do |map|
|
||||
|
||||
Reference in New Issue
Block a user