diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2018-11-19 19:06:40 -0500 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2018-11-19 19:06:40 -0500 |
commit | 4aad2e2228b2127680e6b5aaba5c0cf0e09b1467 (patch) | |
tree | a8f0e436b5b7ea11aa2c2188d7ccd05f10b8908a /actionpack/test | |
parent | 0bbe3409b52d6f7c29a29fbcb9e1acf9d3822406 (diff) | |
parent | 0c8dd2cab6793973384f7320c2cb2b832ec38aff (diff) | |
download | rails-4aad2e2228b2127680e6b5aaba5c0cf0e09b1467.tar.gz rails-4aad2e2228b2127680e6b5aaba5c0cf0e09b1467.tar.bz2 rails-4aad2e2228b2127680e6b5aaba5c0cf0e09b1467.zip |
Merge pull request #20865 from colavitam/only-except-behavior
:only and :except are now chained for routing resource(s)
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/resources_test.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb index d336b96eff..d2146f12a5 100644 --- a/actionpack/test/controller/resources_test.rb +++ b/actionpack/test/controller/resources_test.rb @@ -853,6 +853,28 @@ class ResourcesTest < ActionController::TestCase end end + def test_resource_has_show_action_but_does_not_have_destroy_action + with_routing do |set| + set.draw do + resources :products, only: [:show, :destroy], except: :destroy + end + + assert_resource_allowed_routes("products", {}, { id: "1" }, :show, [:index, :new, :create, :edit, :update, :destroy]) + assert_resource_allowed_routes("products", { format: "xml" }, { id: "1" }, :show, [:index, :new, :create, :edit, :update, :destroy]) + end + end + + def test_singleton_resource_has_show_action_but_does_not_have_destroy_action + with_routing do |set| + set.draw do + resource :account, only: [:show, :destroy], except: :destroy + end + + assert_singleton_resource_allowed_routes("accounts", {}, :show, [:new, :create, :edit, :update, :destroy]) + assert_singleton_resource_allowed_routes("accounts", { format: "xml" }, :show, [:new, :create, :edit, :update, :destroy]) + end + end + def test_resource_has_only_create_action_and_named_route with_routing do |set| set.draw do |