aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAccessd <accessd0@gmail.com>2014-10-18 22:24:29 +0400
committerAccessd <accessd0@gmail.com>2014-10-21 12:10:48 +0400
commit2224bf799275056607bf3990749a298a331a5795 (patch)
tree893b8ced3270baba6983cd35039246f331717f80
parentc33b5e841b54357c1589942dc70192ab0b51fc1e (diff)
downloadrails-2224bf799275056607bf3990749a298a331a5795.tar.gz
rails-2224bf799275056607bf3990749a298a331a5795.tar.bz2
rails-2224bf799275056607bf3990749a298a331a5795.zip
fix url generation error message
-rw-r--r--actionpack/lib/action_dispatch/journey/formatter.rb2
-rw-r--r--actionpack/test/journey/router_test.rb10
2 files changed, 11 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/journey/formatter.rb b/actionpack/lib/action_dispatch/journey/formatter.rb
index 59b353b1b7..992c1a9efe 100644
--- a/actionpack/lib/action_dispatch/journey/formatter.rb
+++ b/actionpack/lib/action_dispatch/journey/formatter.rb
@@ -40,7 +40,7 @@ module ActionDispatch
end
message = "No route matches #{Hash[constraints.sort].inspect}"
- message << " missing required keys: #{missing_keys.sort.inspect}" if name
+ message << " missing required keys: #{missing_keys.sort.inspect}" unless missing_keys.empty?
raise ActionController::UrlGenerationError, message
end
diff --git a/actionpack/test/journey/router_test.rb b/actionpack/test/journey/router_test.rb
index 8e90d4100f..fbac86e8ca 100644
--- a/actionpack/test/journey/router_test.rb
+++ b/actionpack/test/journey/router_test.rb
@@ -201,6 +201,16 @@ module ActionDispatch
assert_match(/missing required keys: \[:id\]/, error.message)
end
+ def test_does_not_include_missing_keys_message
+ route_name = "gorby_thunderhorse"
+
+ error = assert_raises(ActionController::UrlGenerationError) do
+ @formatter.generate(route_name, { }, { })
+ end
+
+ assert_no_match(/missing required keys: \[\]/, error.message)
+ end
+
def test_X_Cascade
add_routes @router, [ "/messages(.:format)" ]
resp = @router.serve(rails_env({ 'REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/lol' }))