spree/spree_active_shipping — pull request #57 by TylerRick (2013-02-01 00:17:11+00:00)
Title: shipper_number is "" (being a truthy value), results in "Missing/Invalid Shipper/ShipperNumber" error response from UPS

I've been using ActiveShipping with UPS in the past without problems until I upgraded to 1.3. I checked my active_shipping_wiredump.log and confirmed that it has never included a node in the request before. It was only after upgrading to Spree 1.3 that it started including that node and we started seeing this error.

Even though this preference is defined to have a nil default:

preference :shipper_number, :string, :default => nil

somehow Spree::ActiveShipping::Config[:shipper_number] ended up getting set to "". I suspect it was probably set to "" when I edited the Active Shipping settings in the backend using the new /admin/active_shipping_settings page, since that page submits all settings as strings to the controller.

When Spree::ActiveShipping::Config[:shipper_number] is "", an empty
ShipperNumber 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.