Permalink
Browse files

Merge pull request #47 from biola/preserve_empty_params

Don't remove parameters with empty values.
  • Loading branch information...
2 parents 4a7806f + b24886e commit e36ce4f82d83cbc3d826eaa427acc5e66a0f849b @mwunsch committed Jun 11, 2015
Showing with 9 additions and 3 deletions.
  1. +1 −3 lib/weary/resource.rb
  2. +8 −0 spec/weary/resource_spec.rb
View
@@ -130,10 +130,8 @@ def construct_request(uri, params, credentials=[])
end
end
- # Private: For a set of parameters passed in to build a Request, delete
- # those with no values, and merge them with the defaults.
+ # Private: Merge parameters passed in to build a Request with the defaults.
def normalize_parameters(params)
- params.delete_if {|k,v| v.nil? || v.to_s.empty? }
params.update(defaults)
params
end
@@ -247,6 +247,14 @@
req.params.should eql "user_id=markwunsch"
end
+ it "passes nil value parameters into the request body" do
+ resource = described_class.new "GET", "http://api.twitter.com/version/users/show.json"
+ resource.required :user_id
+ resource.optional :include_entities
+ req = resource.request :user_id => "markwunsch", include_entities: nil
+ req.params.should eql "user_id=markwunsch&include_entities"
+ end
+
it "passes nested hash parameters into the request body" do
resource = described_class.new "GET", "http://github.com/api/v2/json/repos/show/mwunsch/weary"
resource.optional :search

0 comments on commit e36ce4f

Please sign in to comment.