aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb11
-rw-r--r--actionpack/test/dispatch/routing_test.rb12
2 files changed, 16 insertions, 7 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 00659c8bd4..f7fb4ddd7a 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -77,7 +77,6 @@ module ActionDispatch
path
end
-
def app
Constraints.new(
to.respond_to?(:call) ? to : Routing::RouteSet::Dispatcher.new(:defaults => defaults),
@@ -123,7 +122,6 @@ module ActionDispatch
end
end
-
def blocks
if @options[:constraints].present? && !@options[:constraints].is_a?(Hash)
block = @options[:constraints]
@@ -258,17 +256,17 @@ module ActionDispatch
else
name_prefix_set = false
end
-
+
if namespace = options.delete(:namespace)
namespace_set = true
- namespace, @scope[:namespace] = @scope[:namespace], namespace
+ namespace, @scope[:namespace] = @scope[:namespace], (@scope[:namespace] ? "#{@scope[:namespace]}/#{namespace}" : namespace)
else
namespace_set = false
end
if controller = options.delete(:controller)
controller_set = true
- controller, @scope[:controller] = @scope[:controller], @scope[:namespace] ? "#{@scope[:namespace]}/#{controller}" : controller
+ controller, @scope[:controller] = @scope[:controller], (@scope[:namespace] ? "#{@scope[:namespace]}/#{controller}" : controller)
else
controller_set = false
end
@@ -277,13 +275,12 @@ module ActionDispatch
unless constraints.is_a?(Hash)
block, constraints = constraints, {}
end
+
constraints, @scope[:constraints] = @scope[:constraints], (@scope[:constraints] || {}).merge(constraints)
blocks, @scope[:blocks] = @scope[:blocks], (@scope[:blocks] || []) + [block]
-
options, @scope[:options] = @scope[:options], (@scope[:options] || {}).merge(options)
yield
-
self
ensure
@scope[:path] = path if path_set
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 952cdb1098..bcd6a5278c 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -99,6 +99,10 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
namespace :account do
resource :subscription, :credit, :credit_card
+
+ namespace :admin do
+ resource :subscription
+ end
end
controller :articles do
@@ -445,6 +449,14 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
end
+ def test_nested_namespace
+ with_test_routes do
+ get '/account/admin/subscription'
+ assert_equal 'account/admin/subscriptions#show', @response.body
+ assert_equal '/account/admin/subscription', account_admin_subscription_path
+ end
+ end
+
def test_articles_with_id
with_test_routes do
get '/articles/rails/1'