aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/routing_test.rb
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2006-06-06 17:59:54 +0000
committerJamis Buck <jamis@37signals.com>2006-06-06 17:59:54 +0000
commite768dc694d917cb2e1f88839a8a616fae7f7719d (patch)
tree3f9dc9cc53b0de1ef9ef9675042567c1af0d1fe6 /actionpack/test/controller/routing_test.rb
parentd3bb2e523605e58b3b169cc3840e950f93130a8d (diff)
downloadrails-e768dc694d917cb2e1f88839a8a616fae7f7719d.tar.gz
rails-e768dc694d917cb2e1f88839a8a616fae7f7719d.tar.bz2
rails-e768dc694d917cb2e1f88839a8a616fae7f7719d.zip
Improve parameter expiry handling to fix sticky-id issue. Add a more informative Route#to_s method.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4441 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller/routing_test.rb')
-rw-r--r--actionpack/test/controller/routing_test.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb
index 51b27a536a..d33cf3c6b3 100644
--- a/actionpack/test/controller/routing_test.rb
+++ b/actionpack/test/controller/routing_test.rb
@@ -837,6 +837,10 @@ class RouteTest < Test::Unit::TestCase
assert_equal '', @route.build_query_string({})
end
+ def test_build_query_string_with_nil_value
+ assert_equal '', @route.build_query_string({:x => nil})
+ end
+
def test_simple_build_query_string
assert_equal '?x=1&y=2', @route.build_query_string(:x => '1', :y => '2')
end
@@ -1337,6 +1341,37 @@ class RouteSetTest < Test::Unit::TestCase
url = set.generate({:controller => "foo/bar", :action => "baz", :id => 7}, current)
assert_equal "/foo/bar/baz/7", url
end
+
+ def test_id_is_not_impossibly_sticky
+ set.draw do |map|
+ map.connect 'foo/:number', :controller => "people", :action => "index"
+ map.connect ':controller/:action/:id'
+ end
+
+ url = set.generate({:controller => "people", :action => "index", :number => 3},
+ {:controller => "people", :action => "index", :id => "21"})
+ assert_equal "/foo/3", url
+ end
+
+ def test_id_is_sticky_when_it_ought_to_be
+ set.draw do |map|
+ map.connect ':controller/:id/:action'
+ end
+
+ url = set.generate({:action => "destroy"}, {:controller => "people", :action => "show", :id => "7"})
+ assert_equal "/people/7/destroy", url
+ end
+
+ def test_use_static_path_when_possible
+ set.draw do |map|
+ map.connect 'about', :controller => "welcome", :action => "about"
+ map.connect ':controller/:action/:id'
+ end
+
+ url = set.generate({:controller => "welcome", :action => "about"},
+ {:controller => "welcome", :action => "get", :id => "7"})
+ assert_equal "/about", url
+ end
end
class RoutingTest < Test::Unit::TestCase