From 0df8f6e90594984560ce923bfd7ae266adb26044 Mon Sep 17 00:00:00 2001 From: David Backeus Date: Thu, 4 Mar 2010 15:49:53 +0100 Subject: [PATCH] Fixed handling of arrays --- lib/restclient/payload.rb | 2 +- spec/payload_spec.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/restclient/payload.rb b/lib/restclient/payload.rb index 43b779a..916e71c 100644 --- a/lib/restclient/payload.rb +++ b/lib/restclient/payload.rb @@ -61,7 +61,7 @@ module RestClient result += flatten_params(value, calculated_key) elsif value.is_a? Array value.each do |elem| - result << [calculated_key, elem] + result << ["#{calculated_key}[]", elem] end else result << [calculated_key, value] diff --git a/spec/payload_spec.rb b/spec/payload_spec.rb index 85abaf6..4500858 100644 --- a/spec/payload_spec.rb +++ b/spec/payload_spec.rb @@ -33,11 +33,11 @@ describe RestClient::Payload do should == "foo[bar]=baz" end - it "should properyl handle arrays as repeated parameters" do + it "should properly handle arrays as repeated parameters" do RestClient::Payload::UrlEncoded.new({:foo => ['bar']}).to_s. - should == "foo=bar" + should == "foo[]=bar" RestClient::Payload::UrlEncoded.new({:foo => ['bar', 'baz']}).to_s. - should == "foo=bar&foo=baz" + should == "foo[]=bar&foo[]=baz" end end