aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/routing_test.rb
diff options
context:
space:
mode:
authorYang Bo <yangbodotnet@gmail.com>2015-04-08 22:18:56 +0800
committerYang Bo <yangbodotnet@gmail.com>2015-04-08 22:18:56 +0800
commita77de09812eec5f342dd159f053038c6f67e6da4 (patch)
treebcfee53c34e625d9e22c0f0cf49a7dcba4573f67 /actionpack/test/dispatch/routing_test.rb
parenta05f3e5f96f7a8aa55483d91becdbe49b81833fd (diff)
downloadrails-a77de09812eec5f342dd159f053038c6f67e6da4.tar.gz
rails-a77de09812eec5f342dd159f053038c6f67e6da4.tar.bz2
rails-a77de09812eec5f342dd159f053038c6f67e6da4.zip
sort_by instead of sort
it is avoid sort errot within different and mixed keys. used `sort_by` + `block` to list parameter by keys. keep minimum changes
Diffstat (limited to 'actionpack/test/dispatch/routing_test.rb')
-rw-r--r--actionpack/test/dispatch/routing_test.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 55fc160ac8..62c99a2edc 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -4476,6 +4476,19 @@ class TestUrlGenerationErrors < ActionDispatch::IntegrationTest
error = assert_raises(ActionController::UrlGenerationError, message){ product_path(id: nil) }
assert_equal message, error.message
end
+
+ test "url helpers raise message with mixed parameters when generation fails " do
+ url, missing = { action: 'show', controller: 'products', id: nil, "id"=>"url-tested"}, [:id]
+ message = "No route matches #{url.inspect} missing required keys: #{missing.inspect}"
+
+ # Optimized url helper
+ error = assert_raises(ActionController::UrlGenerationError){ product_path(nil, 'id'=>'url-tested') }
+ assert_equal message, error.message
+
+ # Non-optimized url helper
+ error = assert_raises(ActionController::UrlGenerationError, message){ product_path(id: nil, 'id'=>'url-tested') }
+ assert_equal message, error.message
+ end
end
class TestDefaultUrlOptions < ActionDispatch::IntegrationTest