Permalink
Browse files

Fixed that resource namespaces wouldnt stick to all nested resources (c…

…loses #9399) [pixeltrix]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7447 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
dhh committed Sep 10, 2007
1 parent bf8a4b0 commit b611c685d92038b199149e8eec900c3058523ab7
View
@@ -1,5 +1,7 @@
*SVN*
+* Fixed that resource namespaces wouldn't stick to all nested resources #9399 [pixeltrix]
+
* Moved ActionController::Macros::InPlaceEditing into the in_place_editor plugin on the official Rails svn #9513 [lifofifo]
* Removed deprecated form of calling xml_http_request/xhr without the first argument being the http verb [DHH]
@@ -394,7 +394,7 @@ def map_resource(entities, options = {}, &block)
map_associations(resource, options)
if block_given?
- with_options(:path_prefix => resource.nesting_path_prefix, :name_prefix => resource.nesting_name_prefix, &block)
+ with_options(:path_prefix => resource.nesting_path_prefix, :name_prefix => resource.nesting_name_prefix, :namespace => options[:namespace], &block)
end
end
end
@@ -411,22 +411,21 @@ def map_singleton_resource(entities, options = {}, &block)
map_associations(resource, options)
if block_given?
- with_options(:path_prefix => resource.nesting_path_prefix, :name_prefix => resource.nesting_name_prefix, &block)
+ with_options(:path_prefix => resource.nesting_path_prefix, :name_prefix => resource.nesting_name_prefix, :namespace => options[:namespace], &block)
end
end
end
def map_associations(resource, options)
path_prefix = "#{options.delete(:path_prefix)}#{resource.nesting_path_prefix}"
name_prefix = "#{options.delete(:name_prefix)}#{resource.nesting_name_prefix}"
- namespace = options.delete(:namespace)
Array(options[:has_many]).each do |association|
- resources(association, :path_prefix => path_prefix, :name_prefix => name_prefix, :namespace => namespace)
+ resources(association, :path_prefix => path_prefix, :name_prefix => name_prefix, :namespace => options[:namespace])
end
Array(options[:has_one]).each do |association|
- resource(association, :path_prefix => path_prefix, :name_prefix => name_prefix, :namespace => namespace)
+ resource(association, :path_prefix => path_prefix, :name_prefix => name_prefix, :namespace => options[:namespace])
end
end
@@ -19,9 +19,11 @@ module Backoffice
class ProductsController < ResourcesController; end
class TagsController < ResourcesController; end
class ManufacturersController < ResourcesController; end
+ class ImagesController < ResourcesController; end
module Admin
class ProductsController < ResourcesController; end
+ class ImagesController < ResourcesController; end
end
end
@@ -576,6 +578,36 @@ def test_resources_using_namespace
assert_simply_restful_for :products, :controller => "backoffice/products"
end
end
+
+ def test_nested_resources_using_namespace
+ with_routing do |set|
+ set.draw do |map|
+ map.namespace :backoffice do |backoffice|
+ backoffice.resources :products do |products|
+ products.resources :images
+ end
+ end
+ end
+
+ assert_simply_restful_for :images, :controller => "backoffice/images", :name_prefix => 'backoffice_product_', :path_prefix => 'backoffice/products/1/', :options => {:product_id => '1'}
+ end
+ end
+
+ def test_nested_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 do |products|
+ products.resources :images
+ end
+ end
+ end
+ end
+
+ assert_simply_restful_for :images, :controller => "backoffice/admin/images", :name_prefix => 'backoffice_admin_product_', :path_prefix => 'backoffice/admin/products/1/', :options => {:product_id => '1'}
+ end
+ end
protected
def with_restful_routing(*args)

0 comments on commit b611c68

Please sign in to comment.