-
Notifications
You must be signed in to change notification settings - Fork 547
Calculates UPS delivery date for rate estimates #38
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ def initialize(origin, destination, carrier, service_name, options={}) | |
@total_price = Package.cents_from(options[:total_price]) | ||
@currency = options[:currency] | ||
@delivery_range = options[:delivery_range] ? options[:delivery_range].map { |date| date_for(date) }.compact : [] | ||
@delivery_date = @delivery_range.last | ||
@delivery_date = options[:delivery_date] ? options[:delivery_date] : @delivery_range.last | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With @jduff's suggestion, this change isn't needed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can refactor this into:
|
||
end | ||
|
||
def total_price | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,8 @@ def test_response_parsing | |
"UPS Next Day Air Early A.M.", | ||
"UPS Next Day Air"], response.rates.map(&:service_name) | ||
assert_equal [992, 2191, 3007, 5509, 9401, 6124], response.rates.map(&:price) | ||
assert_equal [nil, 3, 2, 1, 1, 1].map{|days| days ? days.days.from_now.strftime("%Y-%m-%d"): days}, | ||
response.rates.map{|rate| rate.delivery_date ? rate.delivery_date.strftime("%Y-%m-%d") : rate.delivery_date} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would split this up into multiple lines, kind of hard to parse with my old eyes :P There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
end | ||
|
||
def test_maximum_weight | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to set
:delivery_range => [delivery_date]
here instead, that way bothdelivery_range
anddelivery_date
will be set on the estimate. I think it's fine for:delivery_range
to only have one entry and having both set will make the api less confusing (do I need to call delivery_date or delivery_range? Am I Fedex or UPS?)