Skip to content

Commit

Permalink
Make sure namespaces are nested within resources
Browse files Browse the repository at this point in the history
Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information
DefV authored and josevalim committed Jun 8, 2010
1 parent db23a95 commit 4560385
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions actionpack/lib/action_dispatch/routing/mapper.rb
Expand Up @@ -679,6 +679,14 @@ def nested
end
end

def namespace(path)
if @scope[:scope_level] == :resources
nested { super }
else
super
end
end

def match(*args)
options = args.extract_options!

Expand Down
15 changes: 15 additions & 0 deletions actionpack/test/dispatch/routing_test.rb
Expand Up @@ -144,6 +144,12 @@ def self.matches?(request)

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
Expand Down Expand Up @@ -813,6 +819,15 @@ def test_nested_namespace
assert_equal '/account/admin/subscription', account_admin_subscription_path
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
Expand Down

0 comments on commit 4560385

Please sign in to comment.