Permalink
Browse files

Ignore values that aren't included in our expected addresses when bui…

…lding that part

of the query.
  • Loading branch information...
1 parent 2398001 commit 471f4a56fa3de27506f310f4c261b4dc44c374ae @csaunders csaunders committed Jun 6, 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.present? }
+ ary = address.map{ |key, value| [LOOKUPS[:destination_address][key], value] if LOOKUPS[:destination_address].include?(key) && value.present? }
Hash[ary.compact]
end
@@ -270,6 +270,13 @@ def test_building_address_skips_nil_values
end
end
+ def test_building_a_full_query_does_not_cause_query_to_fail
+ @address[:company] = "Powerthirst Inc."
+
+ constructed_address = @service.send(:build_address, @address)
+ assert !constructed_address[nil]
+ end
+
private
def build_mock_response(response, message, code = "200")
http_response = mock(:code => code, :message => message)

0 comments on commit 471f4a5

Please sign in to comment.