Merge pull request #4988 from kennyj/fix_4720-3

Fix GH #4720. Routing problem with nested namespace and already camelized controller option.
This commit is contained in:
Aaron Patterson
2012-02-10 10:00:20 -08:00
parent 6d17b36778
commit 73fcbaaa78
2 changed files with 31 additions and 0 deletions

View File

@@ -31,6 +31,7 @@ module ActionDispatch
end
def prepare_params!(params)
normalize_controller!(params)
merge_default_action!(params)
split_glob_param!(params) if @glob_param
end
@@ -66,6 +67,10 @@ module ActionDispatch
controller.action(action).call(env)
end
def normalize_controller!(params)
params[:controller] = params[:controller].underscore if params.key?(:controller)
end
def merge_default_action!(params)
params[:action] ||= 'index'
end

View File

@@ -2448,6 +2448,32 @@ class TestAppendingRoutes < ActionDispatch::IntegrationTest
end
end
class TestNamespaceWithControllerOption < ActionDispatch::IntegrationTest
module ::Admin
class StorageFilesController < ActionController::Base
def index
render :text => "admin/storage_files#index"
end
end
end
DefaultScopeRoutes = ActionDispatch::Routing::RouteSet.new
DefaultScopeRoutes.draw do
namespace :admin do
resources :storage_files, :controller => "StorageFiles"
end
end
def app
DefaultScopeRoutes
end
def test_controller_options
get '/admin/storage_files'
assert_equal "admin/storage_files#index", @response.body
end
end
class TestDefaultScope < ActionDispatch::IntegrationTest
module ::Blog
class PostsController < ActionController::Base