From 3b1d271e02e3f5b468b2a1ed3fc2a8bd2f228bd4 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Tue, 5 Jul 2005 15:06:09 +0000 Subject: Routing fix git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1712 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/routing.rb | 4 ++-- actionpack/test/controller/routing_test.rb | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index 7be27b2eea..64657a3821 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -118,8 +118,8 @@ module ActionController gp = g.dup # Use another generator to write the conditions after the first && # We do this to ensure that the generator will not assume x_value is set. It will # not be set if it follows a false condition -- for example, false && (x = 2) - - gp.after.map {|c| c.default_check gp} + + check += gp.after.map {|c| c.default_check gp} gp.if(check.join(' && ')) { gp.finish } # If this condition is met, we stop here true end diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 55cf5d8e94..1243b0a6a9 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -682,6 +682,17 @@ class RouteSetTests < Test::Unit::TestCase {:controller => 'admin/user', :action => 'index'} ) end + + def test_backwards + rs.draw do |map| + rs.connect 'page/:id/:action', :controller => 'pages', :action => 'show' + rs.connect ':controller/:action/:id' + end + + assert_equal ['/page/20', {}], rs.generate(:controller => 'pages', :id => 20) + assert_equal ['/page/20', {}], rs.generate(:controller => 'pages', :id => 20, :action => 'show') + assert_equal ['/pages/boo', {}], rs.generate(:controller => 'pages', :action => 'boo') + end end end -- cgit v1.2.3