Permalink
Browse files

When Spree::ActiveShipping::Config[:shipper_number] is "", an empty S…

…hipperNumber node is added to the request, resulting in a "Missing/Invalid Shipper/ShipperNumber" error response from UPS.

By adding .presence, we can have it treat a "" value as nil so that it will skip adding the
ShipperNumber node when shipper_number is "" instead of treating "" as a truthy value.

Fixes #57
  • Loading branch information...
1 parent ea43ab6 commit c85c26bdbee34630663790ec270fe1a76b4518d0 @TylerRick TylerRick committed with radar Jan 31, 2013
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/spree/active_shipping/ups_override.rb
@@ -88,7 +88,7 @@ def build_rate_request(origin, destination, packages, options={})
# * Shipment/RateInformation element
#SPREE OVERRIDE Negotiated Rates
- if (origin_account = @options[:origin_account] || options[:origin_account])
+ if (origin_account = @options[:origin_account].presence || options[:origin_account].presence)
shipment << XmlNode.new("RateInformation") do |rate_information|
rate_information << XmlNode.new("NegotiatedRatesIndicator", '')
end
@@ -157,7 +157,7 @@ def build_location_node(name,location,options={})
location_node << XmlNode.new('PhoneNumber', location.phone.gsub(/[^\d]/,'')) unless location.phone.blank?
location_node << XmlNode.new('FaxNumber', location.fax.gsub(/[^\d]/,'')) unless location.fax.blank?
- if name == 'Shipper' and (origin_account = @options[:origin_account] || options[:origin_account])
+ if name == 'Shipper' and (origin_account = @options[:origin_account].presence || options[:origin_account].presence)
location_node << XmlNode.new('ShipperNumber', origin_account)
elsif name == 'ShipTo' and (destination_account = @options[:destination_account] || options[:destination_account])
location_node << XmlNode.new('ShipperAssignedIdentificationNumber', destination_account)

0 comments on commit c85c26b

Please sign in to comment.