Permalink
Browse files

Make sure we return nil when there's no package.

Will prevent CanadaPost from firing a request with no lineitem that will crash.
  • Loading branch information...
1 parent 6bcf653 commit 86927104e51066872b32fe50c05821c885b9132d @jbourassa jbourassa committed with j15e Jun 28, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 app/models/spree/calculator/active_shipping/base.rb
@@ -36,10 +36,14 @@ def compute(object)
:zip => addr.zipcode)
rates = Rails.cache.fetch(cache_key(order)) do
- rates = retrieve_rates(origin, destination, packages(order))
+ order_packages = packages(order)
+ if order_packages.empty?
+ {}
+ else
+ retrieve_rates(origin, destination, order_packages)
+ end
end
- return nil if rates.empty?
rate = rates[self.class.description]
return nil unless rate
rate = rate.to_f + (Spree::ActiveShipping::Config[:handling_fee].to_f || 0.0)

0 comments on commit 8692710

Please sign in to comment.