aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2010-01-15 14:53:54 -0600
committerJoshua Peek <josh@joshpeek.com>2010-01-15 14:55:13 -0600
commit184ef28f55bb576e1eaebf915f8ce64aa8823e90 (patch)
tree66e5867a013947ad31a0713ad2e819387835985d
parentead93c5be5b0f1945b7d0302f1aae4685ee3f2fb (diff)
downloadrails-184ef28f55bb576e1eaebf915f8ce64aa8823e90.tar.gz
rails-184ef28f55bb576e1eaebf915f8ce64aa8823e90.tar.bz2
rails-184ef28f55bb576e1eaebf915f8ce64aa8823e90.zip
Routing method shorthand shouldn't clobber :to options
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb4
-rw-r--r--actionpack/test/dispatch/routing_test.rb17
2 files changed, 19 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 277cb48e50..6ff573443b 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -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
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 87d8d7730a..2fcc5fef35 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -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'