Permalink
Browse files

Merge pull request #4988 from kennyj/fix_4720-3

Fix GH #4720. Routing problem with nested namespace and already camelized controller option.
  • Loading branch information...
1 parent 6d17b36 commit 73fcbaaa788f781a15d1fe7f8fae2e4b53c799fa @tenderlove tenderlove committed Feb 10, 2012
Showing with 31 additions and 0 deletions.
  1. +5 −0 actionpack/lib/action_dispatch/routing/route_set.rb
  2. +26 −0 actionpack/test/dispatch/routing_test.rb
@@ -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
@@ -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
@@ -2448,6 +2448,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

0 comments on commit 73fcbaa

Please sign in to comment.