test/unit/carriers/shipwire_test.rb in active_shipping-1.7.3 vs test/unit/carriers/shipwire_test.rb in active_shipping-1.8.0
- old
+ new
@@ -22,71 +22,69 @@
end
end
def test_successfully_get_international_rates
date = DateTime.new(2011, 8, 1)
- DateTime.expects(:now).returns(date).at_least_once
@carrier.expects(:ssl_post).returns(xml_fixture('shipwire/international_rates_response'))
- response = @carrier.find_rates(
- location_fixtures[:ottawa],
- location_fixtures[:london],
- package_fixtures.values_at(:book, :wii),
- :order_id => '#1000',
- :items => @items
- )
+ Timecop.freeze(date) do
+ response = @carrier.find_rates(
+ location_fixtures[:ottawa],
+ location_fixtures[:london],
+ package_fixtures.values_at(:book, :wii),
+ :order_id => '#1000',
+ :items => @items
+ )
- assert response.success?
+ assert response.success?
- assert_equal 1, response.rates.size
+ assert_equal 1, response.rates.size
- assert international = response.rates.first
- assert_equal "INTL", international.service_code
- assert_equal "UPS", international.carrier
- assert_equal "UPS Standard", international.service_name
- assert_equal 2806, international.total_price
- assert_equal date + 7, international.delivery_date
- assert_equal [date + 1, date + 7], international.delivery_range
+ assert international = response.rates.first
+ assert_equal "INTL", international.service_code
+ assert_equal "UPS", international.carrier
+ assert_equal "UPS Standard", international.service_name
+ assert_equal 2806, international.total_price
+ assert_equal [date + 1.day, date + 7.days], international.delivery_range
+ end
end
def test_successfully_get_domestic_rates
date = DateTime.new(2011, 8, 1)
- DateTime.expects(:now).returns(date).at_least_once
@carrier.expects(:ssl_post).returns(xml_fixture('shipwire/rates_response'))
- response = @carrier.find_rates(
- location_fixtures[:ottawa],
- location_fixtures[:beverly_hills],
- package_fixtures.values_at(:book, :wii),
- :order_id => '#1000',
- :items => @items
- )
+ Timecop.freeze(date) do
+ response = @carrier.find_rates(
+ location_fixtures[:ottawa],
+ location_fixtures[:beverly_hills],
+ package_fixtures.values_at(:book, :wii),
+ :order_id => '#1000',
+ :items => @items
+ )
- assert response.success?
+ assert response.success?
- assert_equal 3, response.rates.size
+ assert_equal 3, response.rates.size
- assert ground = response.rates.find { |r| r.service_code == "GD" }
- assert_equal "UPS", ground.carrier
- assert_equal "UPS Ground", ground.service_name
- assert_equal 773, ground.total_price
- assert_equal date + 7, ground.delivery_date
- assert_equal [date + 1, date + 7], ground.delivery_range
+ assert ground = response.rates.find { |r| r.service_code == "GD" }
+ assert_equal "UPS", ground.carrier
+ assert_equal "UPS Ground", ground.service_name
+ assert_equal 773, ground.total_price
+ assert_equal [date + 1.day, date + 7.days], ground.delivery_range
- assert two_day = response.rates.find { |r| r.service_code == "2D" }
- assert_equal "UPS", two_day.carrier
- assert_equal "UPS Second Day Air", two_day.service_name
- assert_equal 1364, two_day.total_price
- assert_equal date + 2, two_day.delivery_date
- assert_equal [date + 2, date + 2], two_day.delivery_range
+ assert two_day = response.rates.find { |r| r.service_code == "2D" }
+ assert_equal "UPS", two_day.carrier
+ assert_equal "UPS Second Day Air", two_day.service_name
+ assert_equal 1364, two_day.total_price
+ assert_equal [date + 2.days, date + 2.days], two_day.delivery_range
- assert one_day = response.rates.find { |r| r.service_code == "1D" }
- assert_equal "USPS", one_day.carrier
- assert_equal "USPS Express Mail", one_day.service_name
- assert_equal 2525, one_day.total_price
- assert_equal date + 1, one_day.delivery_date
- assert_equal [date + 1, date + 1], one_day.delivery_range
+ assert one_day = response.rates.find { |r| r.service_code == "1D" }
+ assert_equal "USPS", one_day.carrier
+ assert_equal "USPS Express Mail", one_day.service_name
+ assert_equal 2525, one_day.total_price
+ assert_equal [date + 1.day, date + 1.day], one_day.delivery_range
+ end
end
def test_gracefully_handle_new_carrier
@carrier.expects(:ssl_post).returns(xml_fixture('shipwire/new_carrier_rate_response'))
@@ -165,10 +163,9 @@
:items => @items
)
assert response.success?
assert_equal [], response.rates[0].delivery_range
- assert_nil response.rates[0].delivery_date
end
def test_rate_request_includes_company_if_provided
company = CGI.escape("<Company>Tampa Company</Company>")
@carrier.expects(:ssl_post).with(anything, includes(company)).returns(xml_fixture('shipwire/rates_response'))