aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-02-17 01:46:29 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-02-17 01:46:29 +0000
commit29066036f2c061d9aab1ab1dc2423e01626959c2 (patch)
tree574eb7d7540b1d090b11cb9f5f7a3b8f94421a56 /actionpack
parentc00bf5f0c62f72f84629c6873791a591c02ae62c (diff)
downloadrails-29066036f2c061d9aab1ab1dc2423e01626959c2.tar.gz
rails-29066036f2c061d9aab1ab1dc2423e01626959c2.tar.bz2
rails-29066036f2c061d9aab1ab1dc2423e01626959c2.zip
Make Routes drop the default for action when the controller changes #651
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@640 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/routing.rb1
-rw-r--r--actionpack/test/controller/routing_tests.rb9
2 files changed, 8 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb
index 39ce487e62..07c68e3574 100644
--- a/actionpack/lib/action_controller/routing.rb
+++ b/actionpack/lib/action_controller/routing.rb
@@ -224,6 +224,7 @@ module ActionController
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 cdc9c4e53c..5a8df3a3f4 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 @@ class RouteSetTests < Test::Unit::TestCase
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'