mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Routing method shorthand shouldn't clobber :to options
This commit is contained in:
@@ -560,10 +560,10 @@ module ActionDispatch
|
||||
if args.first.is_a?(Symbol)
|
||||
action = args.first
|
||||
if CRUD_ACTIONS.include?(action)
|
||||
return match("(.:format)", options.merge(:to => action))
|
||||
return match("(.:format)", options.reverse_merge(:to => action))
|
||||
else
|
||||
with_exclusive_name_prefix(action) do
|
||||
return match("/#{action_path(action, resources_path_names)}(.:format)", options.merge(:to => action))
|
||||
return match("/#{action_path(action, resources_path_names)}(.:format)", options.reverse_merge(:to => action))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -97,6 +97,13 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
resources :replies do
|
||||
member do
|
||||
put :answer, :to => :mark_as_answer
|
||||
delete :answer, :to => :unmark_as_answer
|
||||
end
|
||||
end
|
||||
|
||||
resources :posts, :only => [:index, :show]
|
||||
|
||||
match 'sprockets.js' => ::TestRoutingMapper::SprocketsApp
|
||||
@@ -437,6 +444,16 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
def test_replies
|
||||
with_test_routes do
|
||||
put '/replies/1/answer'
|
||||
assert_equal 'replies#mark_as_answer', @response.body
|
||||
|
||||
delete '/replies/1/answer'
|
||||
assert_equal 'replies#unmark_as_answer', @response.body
|
||||
end
|
||||
end
|
||||
|
||||
def test_posts
|
||||
with_test_routes do
|
||||
get '/posts'
|
||||
|
||||
Reference in New Issue
Block a user