aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/routing_test.rb
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2007-02-04 19:07:08 +0000
committerRick Olson <technoweenie@gmail.com>2007-02-04 19:07:08 +0000
commit7a49cb058f5a8345d55f321d6e6bd9dcac22519a (patch)
tree97d90c030af82ef46da871ff92728d8ac9faa916 /actionpack/test/controller/routing_test.rb
parent0a454cd73e9644b154d72b573bc58451010f0e1a (diff)
downloadrails-7a49cb058f5a8345d55f321d6e6bd9dcac22519a.tar.gz
rails-7a49cb058f5a8345d55f321d6e6bd9dcac22519a.tar.bz2
rails-7a49cb058f5a8345d55f321d6e6bd9dcac22519a.zip
fix form_for example in ActionController::Resources documentation. Closes #7362 [gnarg], Added enhanced docs to routing assertions. Closes #7359 [Rob Sanheim], improve error message for Routing for named routes. Closes #7346 [Rob Sanheim]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6113 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller/routing_test.rb')
-rw-r--r--actionpack/test/controller/routing_test.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb
index 0c8628fbf7..f81d0393f0 100644
--- a/actionpack/test/controller/routing_test.rb
+++ b/actionpack/test/controller/routing_test.rb
@@ -242,7 +242,39 @@ class LegacyRouteSetTests < Test::Unit::TestCase
map.connect ':controller/:action/:id'
end
end
+
+ def test_should_list_options_diff_when_routing_requirements_dont_match
+ rs.draw do |map|
+ map.post 'post/:id', :controller=> 'post', :action=> 'show', :requirements => {:id => /\d+/}
+ end
+ exception = assert_raise(ActionController::RoutingError) { rs.generate(:controller => 'post', :action => 'show', :bad_param => "foo", :use_route => "post") }
+ assert_match /^post_url failed to generate/, exception.message
+ from_match = exception.message.match(/from \{[^\}]+\}/).to_s
+ assert_match /:bad_param=>"foo"/, from_match
+ assert_match /:action=>"show"/, from_match
+ assert_match /:controller=>"post"/, from_match
+
+ expected_match = exception.message.match(/expected: \{[^\}]+\}/).to_s
+ assert_no_match /:bad_param=>"foo"/, expected_match
+ assert_match /:action=>"show"/, expected_match
+ assert_match /:controller=>"post"/, expected_match
+ diff_match = exception.message.match(/diff: \{[^\}]+\}/).to_s
+ assert_match /:bad_param=>"foo"/, diff_match
+ assert_no_match /:action=>"show"/, diff_match
+ assert_no_match /:controller=>"post"/, diff_match
+ end
+
+ # this specifies the case where your formerly would get a very confusing error message with an empty diff
+ def test_should_have_better_error_message_when_options_diff_is_empty
+ rs.draw do |map|
+ map.content '/content/:query', :controller => 'content', :action => 'show'
+ end
+ exception = assert_raise(ActionController::RoutingError) { rs.generate(:controller => 'content', :action => 'show', :use_route => "content") }
+ expected_message = %[content_url failed to generate from {:action=>"show", :controller=>"content"} - you may have ambiguous routes, or you may need to supply additional parameters for this route. content_url has the following required parameters: ["content", :query] - are they all satisifed?]
+ assert_equal expected_message, exception.message
+ end
+
def test_dynamic_path_allowed
rs.draw do |map|
map.connect '*path', :controller => 'content', :action => 'show_file'