0
@@ -822,6 +822,84 @@ class ResourcesTest < Test::Unit::TestCase
0
+ def test_resource_has_only_create_action_and_named_route
0
+ map.resources :products, :only => :create
0
+ assert_resource_allowed_routes('products', {}, { :id => '1' }, :create, [:index, :new, :show, :edit, :update, :destroy])
0
+ assert_resource_allowed_routes('products', { :format => 'xml' }, { :id => '1' }, :create, [:index, :new, :show, :edit, :update, :destroy])
0
+ assert_not_nil set.named_routes[:products]
0
+ def test_resource_has_only_update_action_and_named_route
0
+ map.resources :products, :only => :update
0
+ assert_resource_allowed_routes('products', {}, { :id => '1' }, :update, [:index, :new, :create, :show, :edit, :destroy])
0
+ assert_resource_allowed_routes('products', { :format => 'xml' }, { :id => '1' }, :update, [:index, :new, :create, :show, :edit, :destroy])
0
+ assert_not_nil set.named_routes[:product]
0
+ def test_resource_has_only_destroy_action_and_named_route
0
+ map.resources :products, :only => :destroy
0
+ assert_resource_allowed_routes('products', {}, { :id => '1' }, :destroy, [:index, :new, :create, :show, :edit, :update])
0
+ assert_resource_allowed_routes('products', { :format => 'xml' }, { :id => '1' }, :destroy, [:index, :new, :create, :show, :edit, :update])
0
+ assert_not_nil set.named_routes[:product]
0
+ def test_singleton_resource_has_only_create_action_and_named_route
0
+ map.resource :account, :only => :create
0
+ assert_singleton_resource_allowed_routes('accounts', {}, :create, [:new, :show, :edit, :update, :destroy])
0
+ assert_singleton_resource_allowed_routes('accounts', { :format => 'xml' }, :create, [:new, :show, :edit, :update, :destroy])
0
+ assert_not_nil set.named_routes[:account]
0
+ def test_singleton_resource_has_only_update_action_and_named_route
0
+ map.resource :account, :only => :update
0
+ assert_singleton_resource_allowed_routes('accounts', {}, :update, [:new, :create, :show, :edit, :destroy])
0
+ assert_singleton_resource_allowed_routes('accounts', { :format => 'xml' }, :update, [:new, :create, :show, :edit, :destroy])
0
+ assert_not_nil set.named_routes[:account]
0
+ def test_singleton_resource_has_only_destroy_action_and_named_route
0
+ map.resource :account, :only => :destroy
0
+ assert_singleton_resource_allowed_routes('accounts', {}, :destroy, [:new, :create, :show, :edit, :update])
0
+ assert_singleton_resource_allowed_routes('accounts', { :format => 'xml' }, :destroy, [:new, :create, :show, :edit, :update])
0
+ assert_not_nil set.named_routes[:account]
0
def test_resource_has_only_collection_action
This causes issues with singleton resources whereby the named resource route refers to the create action and not the show action, there is a fix in LH #1400
Thanks geoff, applied.