Allow namespace accept options in routes [#4936 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
parent
fef5cf92ed
commit
aacb83143f
@ -346,9 +346,11 @@ def controller(controller)
|
||||
scope(controller.to_sym) { yield }
|
||||
end
|
||||
|
||||
def namespace(path)
|
||||
def namespace(path, options = {})
|
||||
path = path.to_s
|
||||
scope(:path => path, :as => path, :module => path, :shallow_path => path, :shallow_prefix => path) { yield }
|
||||
options = { :path => path, :as => path, :module => path,
|
||||
:shallow_path => path, :shallow_prefix => path }.merge!(options)
|
||||
scope(options) { yield }
|
||||
end
|
||||
|
||||
def constraints(constraints = {})
|
||||
@ -686,7 +688,7 @@ def nested
|
||||
end
|
||||
end
|
||||
|
||||
def namespace(path)
|
||||
def namespace(path, options = {})
|
||||
if resource_scope?
|
||||
nested { super }
|
||||
else
|
||||
|
@ -242,6 +242,10 @@ def self.matches?(request)
|
||||
end
|
||||
end
|
||||
|
||||
namespace :users, :path => 'usuarios' do
|
||||
root :to => 'home#index'
|
||||
end
|
||||
|
||||
controller :articles do
|
||||
scope '/articles', :as => 'article' do
|
||||
scope :path => '/:title', :title => /[a-z]+/, :as => :with_title do
|
||||
@ -932,6 +936,14 @@ def test_namespace_nested_in_resources
|
||||
end
|
||||
end
|
||||
|
||||
def test_namespace_with_options
|
||||
with_test_routes do
|
||||
get '/usuarios'
|
||||
assert_equal '/usuarios', users_root_path
|
||||
assert_equal 'users/home#index', @response.body
|
||||
end
|
||||
end
|
||||
|
||||
def test_articles_with_id
|
||||
with_test_routes do
|
||||
get '/articles/rails/1'
|
||||
|
Loading…
Reference in New Issue
Block a user