diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2014-03-16 09:15:52 +0000 |
---|---|---|
committer | Andrew White <andyw@pixeltrix.co.uk> | 2014-03-16 09:35:35 +0000 |
commit | bb0518891c4c7cc40ff01d90983b83beb61242af (patch) | |
tree | 10b9f7ed28eb6cfdd968c7c6bb6a8fa3a8b1421f /actionpack/test/dispatch/routing_test.rb | |
parent | af981764686c28db40305adf9cfc308f2e20ab50 (diff) | |
download | rails-bb0518891c4c7cc40ff01d90983b83beb61242af.tar.gz rails-bb0518891c4c7cc40ff01d90983b83beb61242af.tar.bz2 rails-bb0518891c4c7cc40ff01d90983b83beb61242af.zip |
Use nested_scope? not shallow? to determine whether to copy options
The method `shallow?` returns false if the parent resource is a singleton so
we need to check if we're not inside a nested scope before copying the :path
and :as options to their shallow equivalents.
Fixes #14388.
Diffstat (limited to 'actionpack/test/dispatch/routing_test.rb')
-rw-r--r-- | actionpack/test/dispatch/routing_test.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index a47050adce..ab2f0ec8de 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -1958,6 +1958,42 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest assert_equal '/comments/3/preview', preview_comment_path(:id => '3') end + def test_shallow_nested_resources_inside_resource + draw do + resource :membership, shallow: true do + resources :cards + end + end + + get '/membership/cards' + assert_equal 'cards#index', @response.body + assert_equal '/membership/cards', membership_cards_path + + get '/membership/cards/new' + assert_equal 'cards#new', @response.body + assert_equal '/membership/cards/new', new_membership_card_path + + post '/membership/cards' + assert_equal 'cards#create', @response.body + + get '/cards/1' + assert_equal 'cards#show', @response.body + assert_equal '/cards/1', card_path('1') + + get '/cards/1/edit' + assert_equal 'cards#edit', @response.body + assert_equal '/cards/1/edit', edit_card_path('1') + + put '/cards/1' + assert_equal 'cards#update', @response.body + + patch '/cards/1' + assert_equal 'cards#update', @response.body + + delete '/cards/1' + assert_equal 'cards#destroy', @response.body + end + def test_shallow_nested_resources_within_scope draw do scope '/hello' do |