aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJan De Poorter <jan@defv.be>2010-04-14 10:34:42 +0200
committerJosé Valim <jose.valim@gmail.com>2010-06-08 23:21:53 +0200
commit4560385fa4fa6925aa220bbaf6b2608c2bbd7039 (patch)
treee0a6a620b11b7734a8ca9839a7e55f1586022e52 /actionpack
parentdb23a95a616860e4fefa4ef83b396abe7ec0ea71 (diff)
downloadrails-4560385fa4fa6925aa220bbaf6b2608c2bbd7039.tar.gz
rails-4560385fa4fa6925aa220bbaf6b2608c2bbd7039.tar.bz2
rails-4560385fa4fa6925aa220bbaf6b2608c2bbd7039.zip
Make sure namespaces are nested within resources
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb8
-rw-r--r--actionpack/test/dispatch/routing_test.rb15
2 files changed, 23 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 6db8d1aacc..0f267caefe 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -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!
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 5c46f9b971..c4e402afd3 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -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
@@ -813,6 +819,15 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
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