aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2010-08-05 23:16:08 +0200
committerPiotr Sarnacki <drogus@gmail.com>2010-09-05 13:44:37 +0200
commit8958f332bbb552e87fd9f8c78dd11bdeab7897fc (patch)
tree48c2a327173b31427640d2ec6f29767dbb1cd4a7
parente6b93fa6db645d0acf18fc36d99ac8e13cb2091a (diff)
downloadrails-8958f332bbb552e87fd9f8c78dd11bdeab7897fc.tar.gz
rails-8958f332bbb552e87fd9f8c78dd11bdeab7897fc.tar.bz2
rails-8958f332bbb552e87fd9f8c78dd11bdeab7897fc.zip
Implemented resources :foos, :except => :all option
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb13
-rw-r--r--actionpack/test/controller/resources_test.rb12
2 files changed, 20 insertions, 5 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index cee3fd880c..f52fb91e97 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -611,9 +611,18 @@ module ActionDispatch
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
diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb
index d0c144d233..3dc2429dae 100644
--- a/actionpack/test/controller/resources_test.rb
+++ b/actionpack/test/controller/resources_test.rb
@@ -1029,7 +1029,9 @@ class ResourcesTest < ActionController::TestCase
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 @@ class ResourcesTest < ActionController::TestCase
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 @@ class ResourcesTest < ActionController::TestCase
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