mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix a bug where symbols and strings were not behaving the same in the router. [#5431 state:resolved]
This commit is contained in:
parent
2fb0cbec02
commit
b4f304b7b6
2 changed files with 7 additions and 12 deletions
|
@ -726,22 +726,17 @@ module ActionDispatch
|
|||
path = options.delete(:path)
|
||||
action = args.first
|
||||
|
||||
if action.is_a?(Symbol)
|
||||
if action && action.to_s =~ /^[\w_]+$/
|
||||
path = path_for_action(action, path)
|
||||
options[:to] ||= action
|
||||
options[:as] = name_for_action(action, options[:as])
|
||||
options[:action] ||= action
|
||||
options[:as] = name_for_action(action, options[:as])
|
||||
|
||||
with_exclusive_scope do
|
||||
return super(path, options)
|
||||
end
|
||||
elsif resource_method_scope?
|
||||
path = path_for_custom_action
|
||||
if action =~ /^[a-zA-Z][_a-zA-Z0-9]*$/
|
||||
options[:action] ||= action
|
||||
options[:as] = name_for_action(action, options[:as])
|
||||
else
|
||||
options[:as] = name_for_action(options[:as]) if options[:as]
|
||||
end
|
||||
options[:as] = name_for_action(options[:as]) if options[:as]
|
||||
args.push(options)
|
||||
|
||||
with_exclusive_scope do
|
||||
|
|
|
@ -658,7 +658,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
|
|||
|
||||
get '/bookmark/remove'
|
||||
assert_equal 'bookmarks#destroy', @response.body
|
||||
assert_equal '/bookmark/remove', bookmark_remove_path
|
||||
assert_equal '/bookmark/remove', remove_bookmark_path
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1192,7 +1192,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
|
|||
|
||||
def test_match_shorthand_inside_namespace
|
||||
with_test_routes do
|
||||
assert_equal '/account/shorthand', account_shorthand_path
|
||||
assert_equal '/account/shorthand', shorthand_account_path
|
||||
get '/account/shorthand'
|
||||
assert_equal 'account#shorthand', @response.body
|
||||
end
|
||||
|
@ -1244,7 +1244,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
|
|||
|
||||
def test_normalize_namespaced_matches
|
||||
with_test_routes do
|
||||
assert_equal '/account/description', account_description_path
|
||||
assert_equal '/account/description', description_account_path
|
||||
|
||||
get '/account/description'
|
||||
assert_equal 'account#description', @response.body
|
||||
|
|
Loading…
Reference in a new issue