diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index 39ce487e622eb242ca2c7a778c8135e6378e6a7c..07c68e35745ed29c7e2a1ac1bf8a191f8b22569c 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -224,6 +224,7 @@ def expand_controller_path!(options, defaults) else relative_to = defaults[:controller] ? defaults[:controller].split('/')[0..-2].join('/') : '' options[:controller] = relative_to.empty? ? options[:controller] : "#{relative_to}/#{options[:controller]}" + defaults.delete(:action) unless options[:controller] == defaults[:controller] end else options[:controller] = defaults[:controller] diff --git a/actionpack/test/controller/routing_tests.rb b/actionpack/test/controller/routing_tests.rb index cdc9c4e53c3c3e6ecf45c0d51c807f66f4b11610..5a8df3a3f43ed704adb82080c206c7b8ccfa056b 100644 --- a/actionpack/test/controller/routing_tests.rb +++ b/actionpack/test/controller/routing_tests.rb @@ -5,7 +5,6 @@ # ActionController::Routing::RailsRoute: 0 / 4 = 0.00% # ActionController::Routing::Route: 0 / 8 = 0.00% -RAILS_ROOT = "" require File.dirname(__FILE__) + '/../abstract_unit' require 'test/unit' require 'cgi' @@ -394,10 +393,16 @@ def test_generate_no_match assert_raises(ActionController::RoutingError) {@set.generate({}, @request)} end - def test_encoded_strings verify_recognize(Controllers::Admin::UserController, {:controller => 'admin/user', :action => 'info', :id => "Nicholas Seckar"}, path='/admin/user/info/Nicholas%20Seckar') end + + def test_action_dropped_when_controller_changes + @request.path_parameters = {:controller => 'content', :action => 'list'} + options = {:controller => 'resource'} + @set.connect ':action/:controller' + verify_generate('index/resource', options) + end end #require '../assertions/action_pack_assertions.rb'