Permalink
Browse files

Implemented resources :foos, :except => :all option

  • Loading branch information...
1 parent e6b93fa commit 8958f332bbb552e87fd9f8c78dd11bdeab7897fc @drogus drogus committed Aug 5, 2010
Showing with 20 additions and 5 deletions.
  1. +11 −2 actionpack/lib/action_dispatch/routing/mapper.rb
  2. +9 −3 actionpack/test/controller/resources_test.rb
@@ -611,9 +611,18 @@ def default_actions
end
def actions
- if only = @options[:only]
+ only, except = @options.values_at(:only, :except)
+ if only == :all || except == :none
+ only = nil
+ except = []
+ elsif only == :none || except == :all
+ only = []
+ except = nil
+ end
+
+ if only
Array(only).map(&:to_sym)
- elsif except = @options[:except]
+ elsif except
default_actions - Array(except).map(&:to_sym)
else
default_actions
@@ -1029,7 +1029,9 @@ def test_singleton_resource_has_only_destroy_action_and_named_route
def test_resource_has_only_collection_action
with_routing do |set|
set.draw do
- resources :products, :except => :all, :collection => { :sale => :get }
+ resources :products, :except => :all do
+ get :sale, :on => :collection
+ end
end
assert_resource_allowed_routes('products', {}, { :id => '1' }, [], [:index, :new, :create, :show, :edit, :update, :destroy])
@@ -1043,7 +1045,9 @@ def test_resource_has_only_collection_action
def test_resource_has_only_member_action
with_routing do |set|
set.draw do
- resources :products, :except => :all, :member => { :preview => :get }
+ resources :products, :except => :all do
+ get :preview, :on => :member
+ end
end
assert_resource_allowed_routes('products', {}, { :id => '1' }, [], [:index, :new, :create, :show, :edit, :update, :destroy])
@@ -1076,7 +1080,9 @@ def test_nested_resource_has_only_show_and_member_action
with_routing do |set|
set.draw do
resources :products, :only => [:index, :show] do
- resources :images, :member => { :thumbnail => :get }, :only => :show
+ resources :images, :only => :show do
+ get :thumbnail, :on => :member
+ end
end
end

0 comments on commit 8958f33

Please sign in to comment.