mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Make sure namespaces are nested within resources
Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
parent
db23a95a61
commit
4560385fa4
2 changed files with 23 additions and 0 deletions
|
@ -679,6 +679,14 @@ module ActionDispatch
|
|||
end
|
||||
end
|
||||
|
||||
def namespace(path)
|
||||
if @scope[:scope_level] == :resources
|
||||
nested { super }
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
def match(*args)
|
||||
options = args.extract_options!
|
||||
|
||||
|
|
|
@ -144,6 +144,12 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
|
|||
|
||||
resources :sheep
|
||||
|
||||
resources :clients do
|
||||
namespace :google do
|
||||
resource :account
|
||||
end
|
||||
end
|
||||
|
||||
match 'sprockets.js' => ::TestRoutingMapper::SprocketsApp
|
||||
|
||||
match 'people/:id/update', :to => 'people#update', :as => :update_person
|
||||
|
@ -814,6 +820,15 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
|
|||
end
|
||||
end
|
||||
|
||||
def test_namespace_nested_in_resources
|
||||
with_test_routes do
|
||||
get '/clients/1/google/account'
|
||||
assert_equal '/clients/1/google/account', client_google_account_path(1)
|
||||
|
||||
assert_equal 'google/accounts#show', @response.body
|
||||
end
|
||||
end
|
||||
|
||||
def test_articles_with_id
|
||||
with_test_routes do
|
||||
get '/articles/rails/1'
|
||||
|
|
Loading…
Reference in a new issue