From 38d8118e09fe6b5af797594f7cd5363faf4b4900 Mon Sep 17 00:00:00 2001 From: Martyn Loughran Date: Mon, 22 Apr 2013 18:02:49 +0100 Subject: [PATCH] Fixed regression handling queries with nil values --- lib/signature/query_encoder.rb | 2 +- spec/signature_spec.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/signature/query_encoder.rb b/lib/signature/query_encoder.rb index 4d62095..ad1802b 100644 --- a/lib/signature/query_encoder.rb +++ b/lib/signature/query_encoder.rb @@ -17,7 +17,7 @@ def encode_param_without_escaping(k, v) if v.is_a?(Array) v.map { |e| k + "[]=" + e }.join("&") else - k + "=" + v + "#{k}=#{v}" end end diff --git a/spec/signature_spec.rb b/spec/signature_spec.rb index f77be90..3d972bf 100644 --- a/spec/signature_spec.rb +++ b/spec/signature_spec.rb @@ -75,6 +75,13 @@ @request.send(:string_to_sign).should == "POST\n/some/path\nkey;=value@" end + it "should cope with requests where the value is nil (antiregression)" do + @request.query_hash = { + "key" => nil + } + @request.send(:string_to_sign).should == "POST\n/some/path\nkey=" + end + it "should use the path to generate signature" do @request.path = '/some/other/path' @request.sign(@token)[:auth_signature].should_not == @signature