Skip to content

Commit

Permalink
Merge pull request #4988 from kennyj/fix_4720-3
Browse files Browse the repository at this point in the history
Fix GH #4720. Routing problem with nested namespace and already camelized controller option.
  • Loading branch information
tenderlove committed Feb 10, 2012
2 parents e6c98b8 + 203b88f commit 415424f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions actionpack/lib/action_dispatch/routing/route_set.rb
Expand Up @@ -31,6 +31,7 @@ def call(env)
end

def prepare_params!(params)
normalize_controller!(params)
merge_default_action!(params)
split_glob_param!(params) if @glob_param
end
Expand Down Expand Up @@ -66,6 +67,10 @@ def dispatch(controller, action, env)
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
Expand Down
26 changes: 26 additions & 0 deletions actionpack/test/dispatch/routing_test.rb
Expand Up @@ -2449,6 +2449,32 @@ def test_missing_routes_are_still_missing
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
Expand Down

0 comments on commit 415424f

Please sign in to comment.