diff --git a/lib/routes_upgrader.rb b/lib/routes_upgrader.rb index 126fc2a..9d98643 100644 --- a/lib/routes_upgrader.rb +++ b/lib/routes_upgrader.rb @@ -304,8 +304,10 @@ module Rails method_code = [] RouteRedrawer.stack << self - @options[group].each do |k, v| - method_code << "#{v} :#{k}" + @options[group].each do |name, methods| + [*methods].each do |method| + method_code << "#{method} :#{name}" + end end RouteRedrawer.stack.pop diff --git a/test/routes_upgrader_test.rb b/test/routes_upgrader_test.rb index e496eb4..eda8135 100644 --- a/test/routes_upgrader_test.rb +++ b/test/routes_upgrader_test.rb @@ -89,6 +89,11 @@ end assert_equal "resources :hats do\ncollection do\npost :toss\nend\nmember do\nget :wear\nend\n\nend\n", route.to_route_code end + def test_generates_code_for_resources_with_multiple_special_methods_per_name + route = Rails::Upgrading::FakeResourceRoute.new("hats", {:member => {:wear => [:get, :put]}, :collection => {:toss => [:get, :post]}}) + assert_equal "resources :hats do\ncollection do\nget :toss\npost :toss\nend\nmember do\nget :wear\nput :wear\nend\n\nend\n", route.to_route_code + end + def test_generates_code_for_route_with_extra_params route = Rails::Upgrading::FakeRoute.new("/about", {:controller => 'static', :action => 'about', :something => 'extra'}) assert_equal "match '/about' => 'static#about', :something => 'extra'", route.to_route_code