Skip to content

Commit

Permalink
Fixed regression handling queries with nil values
Browse files Browse the repository at this point in the history
  • Loading branch information
mloughran committed Apr 22, 2013
1 parent 7efcdca commit 38d8118
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/signature/query_encoder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions spec/signature_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 38d8118

Please sign in to comment.