aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2010-06-22 17:26:35 -0300
committerJosé Valim <jose.valim@gmail.com>2010-06-22 23:37:49 +0200
commitaacb83143f24ff44c046d18930270d650efffec5 (patch)
tree1fc390395eb61408df1cd00aec092d455117c2a0 /actionpack
parentfef5cf92ed883daf663299258549bc7aa454db1e (diff)
downloadrails-aacb83143f24ff44c046d18930270d650efffec5.tar.gz
rails-aacb83143f24ff44c046d18930270d650efffec5.tar.bz2
rails-aacb83143f24ff44c046d18930270d650efffec5.zip
Allow namespace accept options in routes [#4936 state:resolved]
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.rb12
2 files changed, 17 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index e0d18b74d8..77740b0f53 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -346,9 +346,11 @@ module ActionDispatch
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 @@ module ActionDispatch
end
end
- def namespace(path)
+ def namespace(path, options = {})
if resource_scope?
nested { super }
else
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index e250810168..51b241eb1f 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -242,6 +242,10 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
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 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
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'