Provive resources_path_names helpers in the router.

This commit is contained in:
José Valim
2010-06-23 00:43:25 +02:00
parent e5444f84df
commit 61317b643a
2 changed files with 15 additions and 0 deletions

View File

@@ -577,6 +577,10 @@ module ActionDispatch
@scope[:path_names] = @set.resources_path_names
end
def resources_path_names(options)
@scope[:path_names].merge!(options)
end
def resource(*resources, &block)
options = resources.extract_options!
options = (@scope[:options] || {}).merge(options)

View File

@@ -16,6 +16,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
Routes = routes
Routes.draw do
default_url_options :host => "rubyonrails.org"
resources_path_names :correlation_indexes => "info_about_correlation_indexes"
controller :sessions do
get 'login' => :new
@@ -86,6 +87,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
resources :projects, :controller => :project do
resources :involvements, :attachments
get :correlation_indexes, :on => :collection
resources :participants do
put :update_all, :on => :collection
@@ -112,6 +114,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
member do
get :some_path_with_name
put :accessible_projects
post :resend, :generate_new_password
end
@@ -710,6 +713,14 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
end
def test_projects_with_resources_path_names
with_test_routes do
get '/projects/info_about_correlation_indexes'
assert_equal 'project#correlation_indexes', @response.body
assert_equal '/projects/info_about_correlation_indexes', correlation_indexes_projects_path
end
end
def test_projects_posts
with_test_routes do
get '/projects/1/posts'