aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Seckar <nseckar@gmail.com>2006-10-16 19:52:21 +0000
committerNicholas Seckar <nseckar@gmail.com>2006-10-16 19:52:21 +0000
commit03b383853d3e1de85cf1b345e2b0dd5cb1f42479 (patch)
tree6f9918fd360e4884d41e57c43301e83429be2665
parentd1ae92eeb25364d3a50c8dd00c5006f2038e0b19 (diff)
downloadrails-03b383853d3e1de85cf1b345e2b0dd5cb1f42479.tar.gz
rails-03b383853d3e1de85cf1b345e2b0dd5cb1f42479.tar.bz2
rails-03b383853d3e1de85cf1b345e2b0dd5cb1f42479.zip
Fix routing to correctly determine when generation fails. Closes #6300.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5314 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_controller/routing.rb2
-rw-r--r--actionpack/test/controller/routing_test.rb27
3 files changed, 30 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 8673772dcc..94044a8876 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Fix routing to correctly determine when generation fails. Closes #6300. [psross].
+
* Fix broken assert_generates when extra keys are being checked. [Jamis Buck]
* Replace KCODE checks with String#chars for truncate. Closes #6385 [Manfred Stienstra]
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb
index 79ec617cc8..2f24bf4c34 100644
--- a/actionpack/lib/action_controller/routing.rb
+++ b/actionpack/lib/action_controller/routing.rb
@@ -1229,7 +1229,7 @@ module ActionController
routes.each do |route|
results = route.send(method, options, merged, expire_on)
- return results if results
+ return results if results && (!results.is_a?(Array) || results.first)
end
end
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb
index 689a07fcbc..343c9279ea 100644
--- a/actionpack/test/controller/routing_test.rb
+++ b/actionpack/test/controller/routing_test.rb
@@ -1253,6 +1253,33 @@ class RouteSetTest < Test::Unit::TestCase
extras = set.extra_keys(:controller => "foo", :action => "bar", :id => 15, :this => "hello", :that => "world")
assert_equal %w(that this), extras.map(&:to_s).sort
end
+
+ def test_generate_extras_not_first
+ set.draw do |map|
+ map.connect ':controller/:action/:id.:format'
+ map.connect ':controller/:action/:id'
+ end
+ path, extras = set.generate_extras(:controller => "foo", :action => "bar", :id => 15, :this => "hello", :that => "world")
+ assert_equal "/foo/bar/15", path
+ assert_equal %w(that this), extras.map(&:to_s).sort
+ end
+
+ def test_generate_not_first
+ set.draw do |map|
+ map.connect ':controller/:action/:id.:format'
+ map.connect ':controller/:action/:id'
+ end
+ assert_equal "/foo/bar/15?this=hello", set.generate(:controller => "foo", :action => "bar", :id => 15, :this => "hello")
+ end
+
+ def test_extra_keys_not_first
+ set.draw do |map|
+ map.connect ':controller/:action/:id.:format'
+ map.connect ':controller/:action/:id'
+ end
+ extras = set.extra_keys(:controller => "foo", :action => "bar", :id => 15, :this => "hello", :that => "world")
+ assert_equal %w(that this), extras.map(&:to_s).sort
+ end
def test_draw
assert_equal 0, set.routes.size