diff --git a/lib/routes_upgrader.rb b/lib/routes_upgrader.rb index e7b88b7..126fc2a 100644 --- a/lib/routes_upgrader.rb +++ b/lib/routes_upgrader.rb @@ -277,7 +277,9 @@ module Rails def to_route_code # preserve :only & :except options copied_options = @options.reject { |k,v| ![:only, :except].member?(k) } - copied_options_str = copied_options.empty? ? '' : ', ' + copied_options.inspect.gsub(/\A\{|\}\z/, '') + unless copied_options.empty? + copied_options_str = ", " + copied_options.map { |k, v| "#{k.inspect} => #{v.inspect}" }.join(",") + end if !@children.empty? || @options.has_key?(:collection) || @options.has_key?(:member) prefix = ["#{route_method} :#{@name}#{copied_options_str} do"] diff --git a/test/routes_upgrader_test.rb b/test/routes_upgrader_test.rb index c4c658e..e496eb4 100644 --- a/test/routes_upgrader_test.rb +++ b/test/routes_upgrader_test.rb @@ -142,11 +142,11 @@ end def test_preserves_resources_except_option route = Rails::Upgrading::FakeResourceRoute.new("hats", :except => [:index]) - assert_equal "resources :hats, :except=>[:index]", route.to_route_code + assert_equal "resources :hats, :except => [:index]", route.to_route_code end def test_preserves_resources_only_option route = Rails::Upgrading::FakeResourceRoute.new("hats", :only => :show) - assert_equal "resources :hats, :only=>:show", route.to_route_code + assert_equal "resources :hats, :only => :show", route.to_route_code end end \ No newline at end of file