mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Provive resources_path_names helpers in the router.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user