Permalink
Browse files

ensure null keys are ignored

  • Loading branch information...
1 parent e995c6a commit 2398001ed8a7a271f981f71732cd918ac451121a @csaunders csaunders committed Jun 5, 2012
@@ -399,7 +399,7 @@ def build_tracking_request(order_id, options)
def build_address(address)
requires!(address, :name, :address1, :city, :state, :country, :zip)
- ary = address.map{ |key, value| [LOOKUPS[:destination_address][key], value] if value.length > 0 }
+ ary = address.map{ |key, value| [LOOKUPS[:destination_address][key], value] if value.present? }
Hash[ary.compact]
end
@@ -263,6 +263,13 @@ def test_404_error
assert_equal response_from_404, response.http_body
end
+ def test_building_address_skips_nil_values
+ @address[:address2] = nil
+ assert_nothing_raised do
+ @service.send(:build_address, @address)
+ end
+ end
+
private
def build_mock_response(response, message, code = "200")
http_response = mock(:code => code, :message => message)

0 comments on commit 2398001

Please sign in to comment.