mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Ensure nested namespaces work as expected.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user