mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user