Support arrays in member/collection options in the routes upgrader: {:member => {:custom => [:get, :put]}}
This commit is contained in:
parent
0fa6a78f62
commit
5223f9699c
|
@ -304,8 +304,10 @@ module Rails
|
||||||
method_code = []
|
method_code = []
|
||||||
|
|
||||||
RouteRedrawer.stack << self
|
RouteRedrawer.stack << self
|
||||||
@options[group].each do |k, v|
|
@options[group].each do |name, methods|
|
||||||
method_code << "#{v} :#{k}"
|
[*methods].each do |method|
|
||||||
|
method_code << "#{method} :#{name}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
RouteRedrawer.stack.pop
|
RouteRedrawer.stack.pop
|
||||||
|
|
||||||
|
|
|
@ -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
|
assert_equal "resources :hats do\ncollection do\npost :toss\nend\nmember do\nget :wear\nend\n\nend\n", route.to_route_code
|
||||||
end
|
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
|
def test_generates_code_for_route_with_extra_params
|
||||||
route = Rails::Upgrading::FakeRoute.new("/about", {:controller => 'static', :action => 'about', :something => 'extra'})
|
route = Rails::Upgrading::FakeRoute.new("/about", {:controller => 'static', :action => 'about', :something => 'extra'})
|
||||||
assert_equal "match '/about' => 'static#about', :something => 'extra'", route.to_route_code
|
assert_equal "match '/about' => 'static#about', :something => 'extra'", route.to_route_code
|
||||||
|
|
Loading…
Reference in New Issue