From e6ffc535ae7110e2a66fb66859112b5ec935b33c Mon Sep 17 00:00:00 2001 From: Sam Pohlenz Date: Sat, 16 Jan 2010 11:04:29 +1030 Subject: [PATCH] Allow custom controller for resource(s) --- actionpack/lib/action_dispatch/routing/mapper.rb | 2 +- actionpack/test/dispatch/routing_test.rb | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index ce5c56a..9aaa435 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -380,7 +380,7 @@ module ActionDispatch end def controller - plural + options[:controller] || plural end def member_name diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index 5845c79..6dccabd 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -65,7 +65,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest resources :companies do resources :people - resource :avatar + resource :avatar, :controller => :avatar end resources :images do @@ -294,34 +294,34 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest def test_projects with_test_routes do get '/projects' - assert_equal 'projects#index', @response.body + assert_equal 'project#index', @response.body assert_equal '/projects', projects_path post '/projects' - assert_equal 'projects#create', @response.body + assert_equal 'project#create', @response.body get '/projects.xml' - assert_equal 'projects#index', @response.body + assert_equal 'project#index', @response.body assert_equal '/projects.xml', projects_path(:format => 'xml') get '/projects/new' - assert_equal 'projects#new', @response.body + assert_equal 'project#new', @response.body assert_equal '/projects/new', new_project_path get '/projects/new.xml' - assert_equal 'projects#new', @response.body + assert_equal 'project#new', @response.body assert_equal '/projects/new.xml', new_project_path(:format => 'xml') get '/projects/1' - assert_equal 'projects#show', @response.body + assert_equal 'project#show', @response.body assert_equal '/projects/1', project_path(:id => '1') get '/projects/1.xml' - assert_equal 'projects#show', @response.body + assert_equal 'project#show', @response.body assert_equal '/projects/1.xml', project_path(:id => '1', :format => 'xml') get '/projects/1/edit' - assert_equal 'projects#edit', @response.body + assert_equal 'project#edit', @response.body assert_equal '/projects/1/edit', edit_project_path(:id => '1') end end @@ -383,7 +383,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest assert_equal '/projects/1/companies/1/people', project_company_people_path(:project_id => '1', :company_id => '1') get '/projects/1/companies/1/avatar' - assert_equal 'avatars#show', @response.body + assert_equal 'avatar#show', @response.body assert_equal '/projects/1/companies/1/avatar', project_company_avatar_path(:project_id => '1', :company_id => '1') end end -- 1.6.5.7