From 80747e9db16ec60eb0d95b510baf051612ec0768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20T=C3=A4nav?= Date: Fri, 30 Jan 2009 13:37:59 +0200 Subject: Removed map.resources :only/:except inheritance It's very rare for these options to apply identically to nested child resources, and with this inheritance on it's very difficult to have a child resource with more actions than the parent. This reverts commit 2ecec6052f7f290252a9fd9cc27ec804c7aad36c. Signed-off-by: Michael Koziarski [#1826 state:committed] --- actionpack/test/controller/resources_test.rb | 43 ++++++++++++++++++---------- 1 file changed, 28 insertions(+), 15 deletions(-) (limited to 'actionpack/test/controller/resources_test.rb') diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb index 8dedeb23f6..ae2639d245 100644 --- a/actionpack/test/controller/resources_test.rb +++ b/actionpack/test/controller/resources_test.rb @@ -942,19 +942,6 @@ class ResourcesTest < ActionController::TestCase end end - def test_nested_resource_inherits_only_show_action - with_routing do |set| - set.draw do |map| - map.resources :products, :only => :show do |product| - product.resources :images - end - end - - assert_resource_allowed_routes('images', { :product_id => '1' }, { :id => '2' }, :show, [:index, :new, :create, :edit, :update, :destroy], 'products/1/images') - assert_resource_allowed_routes('images', { :product_id => '1', :format => 'xml' }, { :id => '2' }, :show, [:index, :new, :create, :edit, :update, :destroy], 'products/1/images') - end - end - def test_nested_resource_has_only_show_and_member_action with_routing do |set| set.draw do |map| @@ -971,7 +958,7 @@ class ResourcesTest < ActionController::TestCase end end - def test_nested_resource_ignores_only_option + def test_nested_resource_does_not_inherit_only_option with_routing do |set| set.draw do |map| map.resources :products, :only => :show do |product| @@ -984,7 +971,20 @@ class ResourcesTest < ActionController::TestCase end end - def test_nested_resource_ignores_except_option + def test_nested_resource_does_not_inherit_only_option_by_default + with_routing do |set| + set.draw do |map| + map.resources :products, :only => :show do |product| + product.resources :images + end + end + + assert_resource_allowed_routes('images', { :product_id => '1' }, { :id => '2' }, [:index, :new, :create, :show, :edit, :update, :destory], [], 'products/1/images') + assert_resource_allowed_routes('images', { :product_id => '1', :format => 'xml' }, { :id => '2' }, [:index, :new, :create, :show, :edit, :update, :destroy], [], 'products/1/images') + end + end + + def test_nested_resource_does_not_inherit_except_option with_routing do |set| set.draw do |map| map.resources :products, :except => :show do |product| @@ -997,6 +997,19 @@ class ResourcesTest < ActionController::TestCase end end + def test_nested_resource_does_not_inherit_except_option_by_default + with_routing do |set| + set.draw do |map| + map.resources :products, :except => :show do |product| + product.resources :images + end + end + + assert_resource_allowed_routes('images', { :product_id => '1' }, { :id => '2' }, [:index, :new, :create, :show, :edit, :update, :destroy], [], 'products/1/images') + assert_resource_allowed_routes('images', { :product_id => '1', :format => 'xml' }, { :id => '2' }, [:index, :new, :create, :show, :edit, :update, :destroy], [], 'products/1/images') + end + end + def test_default_singleton_restful_route_uses_get with_routing do |set| set.draw do |map| -- cgit v1.2.3