Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate usage of nil as route path #25693

Merged
merged 1 commit into from
Jul 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions actionpack/lib/action_dispatch/routing/mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1562,6 +1562,12 @@ def match(path, *rest)
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
Expand Down
7 changes: 7 additions & 0 deletions actionpack/test/dispatch/routing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,9 @@ def test_pagemarks
post "create", :as => ""
put "update"
get "remove", :action => :destroy, :as => :remove
tc.assert_deprecated do
get action: :show, as: :show
end
end
end

Expand All @@ -391,6 +394,10 @@ def test_pagemarks
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
Expand Down