aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/resources_test.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-05-22 09:37:07 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-05-22 09:37:07 +0000
commit5a3b4cf0bca5453547e89dc82966909b6bde3564 (patch)
treee9dcbdadd8ce7fdd1bd1f9a3ef63968575e221d5 /actionpack/test/controller/resources_test.rb
parent4afd6c9f0a0e97429191af3e3b348ffa4416c640 (diff)
downloadrails-5a3b4cf0bca5453547e89dc82966909b6bde3564.tar.gz
rails-5a3b4cf0bca5453547e89dc82966909b6bde3564.tar.bz2
rails-5a3b4cf0bca5453547e89dc82966909b6bde3564.zip
Resource namespaces are inherited by their has_many subresources. Closes #8280.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6806 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller/resources_test.rb')
-rw-r--r--actionpack/test/controller/resources_test.rb35
1 files changed, 32 insertions, 3 deletions
diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb
index 979008f21b..01836f6b94 100644
--- a/actionpack/test/controller/resources_test.rb
+++ b/actionpack/test/controller/resources_test.rb
@@ -17,9 +17,11 @@ class AdminController < ResourcesController; end
module Backoffice
class ProductsController < ResourcesController; end
-
+ class TagsController < ResourcesController; end
+ class ManufacturerController < ResourcesController; end
+
module Admin
- class ProductsController < ResourcesController; end
+ class ProductsController < ResourcesController; end
end
end
@@ -403,6 +405,32 @@ class ResourcesTest < Test::Unit::TestCase
assert_simply_restful_for :products, :controller => "backoffice/products", :name_prefix => 'backoffice_', :path_prefix => 'backoffice/'
end
end
+
+ def test_resource_has_many_in_namespace
+ with_routing do |set|
+ set.draw do |map|
+ map.namespace :backoffice do |backoffice|
+ backoffice.resources :products, :has_many => :tags
+ end
+ end
+
+ assert_simply_restful_for :products, :controller => "backoffice/products", :name_prefix => 'backoffice_', :path_prefix => 'backoffice/'
+ assert_simply_restful_for :tags, :controller => "backoffice/tags", :name_prefix => "backoffice_product_", :path_prefix => 'backoffice/products/1/', :options => { :product_id => '1' }
+ end
+ end
+
+ def test_resource_has_one_in_namespace
+ with_routing do |set|
+ set.draw do |map|
+ map.namespace :backoffice do |backoffice|
+ backoffice.resources :products, :has_one => :manufacturer
+ end
+ end
+
+ assert_simply_restful_for :products, :controller => "backoffice/products", :name_prefix => 'backoffice_', :path_prefix => 'backoffice/'
+ assert_singleton_restful_for :manufacturer, :controller => "backoffice/manufacturer", :name_prefix => 'backoffice_product_', :path_prefix => 'backoffice/products/1/', :options => { :product_id => '1' }
+ end
+ end
def test_resources_in_nested_namespace
with_routing do |set|
@@ -526,7 +554,8 @@ class ResourcesTest < Test::Unit::TestCase
end
def assert_singleton_routes_for(singleton_name, options = {})
- (options[:options] ||= {})[:controller] ||= singleton_name.to_s
+ options[:options] ||= {}
+ options[:options][:controller] = options[:controller] || singleton_name.to_s
full_path = "/#{options[:path_prefix]}#{singleton_name}"
new_path = "#{full_path}/new"