Skip to content

Commit

Permalink
Ignore values that aren't included in our expected addresses when bui…
Browse files Browse the repository at this point in the history
…lding that part

of the query.
  • Loading branch information
jiblits committed Jun 6, 2012
1 parent 2398001 commit 471f4a5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/active_fulfillment/fulfillment/services/amazon_mws.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions test/unit/services/amazon_mws_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 471f4a5

Please sign in to comment.