aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2016-07-05 13:03:15 -0300
committerGitHub <noreply@github.com>2016-07-05 13:03:15 -0300
commit50819394c8f27fe5343af8398add790d62d63619 (patch)
tree13976d9dce6331a8594212813f63ea72e7bf15ce /actionpack
parent67d5783f96e4adf4b9dd2d8bd60987e3b7020b13 (diff)
parent1fd9cdfda6c4e4473667cb6e28b8097607abc765 (diff)
downloadrails-50819394c8f27fe5343af8398add790d62d63619.tar.gz
rails-50819394c8f27fe5343af8398add790d62d63619.tar.bz2
rails-50819394c8f27fe5343af8398add790d62d63619.zip
Merge pull request #25693 from volmer/master
Deprecate usage of nil as route path
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb6
-rw-r--r--actionpack/test/dispatch/routing_test.rb7
2 files changed, 13 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index e2cf75da3a..73b4864e45 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -1562,6 +1562,12 @@ module ActionDispatch
options = path
path, to = options.find { |name, _value| name.is_a?(String) }
+ if path.nil?
+ ActiveSupport::Deprecation.warn 'Omitting the route path is deprecated. '\
+ 'Specify the path with a String or a Symbol instead.'
+ path = ''
+ end
+
case to
when Symbol
options[:action] = to
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