From 1fd9cdfda6c4e4473667cb6e28b8097607abc765 Mon Sep 17 00:00:00 2001 From: Volmer Date: Mon, 4 Jul 2016 21:58:20 -0400 Subject: Deprecate usage of nil as route path In Rails 4 these kind of routes used to work: ```ruby scope '/*id', controller: :builds, as: :build do get action: :show end ``` But since 1a830cbd830c7f80936dff7e3c8b26f60dcc371d, routes are only created for paths specified as strings or symbols. Implicit `nil` paths are just ignored, with no deprecation warnings or errors. Routes are simply not created. This come as a surprise for people migrating to Rails 5, since the lack of logs or errors makes hard to understand where the problem is. This commit introduces a deprecation warning in case of path as `nil`, while still allowing the route definition. --- actionpack/test/dispatch/routing_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'actionpack/test/dispatch/routing_test.rb') diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index 75fdc9469f..d54cdf7247 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -373,6 +373,9 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest post "create", :as => "" put "update" get "remove", :action => :destroy, :as => :remove + tc.assert_deprecated do + get action: :show, as: :show + end end end @@ -391,6 +394,10 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest get '/pagemark/remove' assert_equal 'pagemarks#destroy', @response.body assert_equal '/pagemark/remove', pagemark_remove_path + + get '/pagemark' + assert_equal 'pagemarks#show', @response.body + assert_equal '/pagemark', pagemark_show_path end def test_admin -- cgit v1.2.3