diff options
author | Jamis Buck <jamis@37signals.com> | 2006-06-05 15:48:29 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2006-06-05 15:48:29 +0000 |
commit | 6c04eb2115cd65d480f1d7c95cbc86a5d39a41ca (patch) | |
tree | 38dc2e06851212ddd06089a1d6d99b71789f1980 | |
parent | f97978ad9137b7a9213fa9d4a58071ac6d23bc7e (diff) | |
download | rails-6c04eb2115cd65d480f1d7c95cbc86a5d39a41ca.tar.gz rails-6c04eb2115cd65d480f1d7c95cbc86a5d39a41ca.tar.bz2 rails-6c04eb2115cd65d480f1d7c95cbc86a5d39a41ca.zip |
Make sure changing the controller from foo/bar to bing/bang does not change relative to foo.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4438 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/routing.rb | 4 | ||||
-rw-r--r-- | actionpack/test/controller/routing_test.rb | 7 |
3 files changed, 12 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index e3c42ea050..33d3342a47 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Make sure changing the controller from foo/bar to bing/bang does not change relative to foo. [Jamis Buck] + * Escape the path before routing recognition. #3671 * Make sure :id and friends are unescaped properly. #5275 [me@julik.nl] diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index 0b8d9c0a73..3590513325 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -955,7 +955,9 @@ module ActionController # on admin/get, and the new controller is 'set', the new controller # should really be admin/set. if expire_on[:controller] && options[:controller] && options[:controller][0] != ?/ - parts = recall[:controller].split('/')[0..-2] + [options[:controller]] + old_parts = recall[:controller].split('/') + new_parts = options[:controller].split('/') + parts = old_parts[0..-(new_parts.length + 1)] + new_parts options[:controller] = parts.join('/') end diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 62bad1fee3..51b27a536a 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -1330,6 +1330,13 @@ class RouteSetTest < Test::Unit::TestCase url = set.generate(:controller => "people", :action => "index", :ws => true) assert_equal "/ws/people", url end + + def test_generate_changes_controller_module + set.draw { |map| map.connect ':controller/:action/:id' } + current = { :controller => "bling/bloop", :action => "bap", :id => 9 } + url = set.generate({:controller => "foo/bar", :action => "baz", :id => 7}, current) + assert_equal "/foo/bar/baz/7", url + end end class RoutingTest < Test::Unit::TestCase |