Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed test failure due to time zones, removed commented-out test

  • Loading branch information...
commit 23d7d2d4eab775007f955d4c06c6b9ec4641eb33 1 parent 7d1e8a1
Dave Rooney authored
Showing with 11 additions and 25 deletions.
  1. +11 −25 test/unit/carriers/fedex_test.rb
View
36 test/unit/carriers/fedex_test.rb
@@ -15,25 +15,22 @@ def test_initialize_options_requirements
assert_nothing_raised { FedEx.new(:key => '999999999', :password => '7777777', :account => '123', :login => '123')}
end
- def test_turn_around_time_default
- mock_response = xml_fixture('fedex/ottawa_to_beverly_hills_rate_response').gsub('<v6:DeliveryTimestamp>2011-07-29</v6:DeliveryTimestamp>', '')
- Timecop.freeze(DateTime.new(2013, 3, 11)) do
- delivery_date = Date.today + 5.days # FIVE_DAYS in fixture response
- timestamp = Time.now.iso8601
- @carrier.expects(:commit).with do |request|
- parsed_response = Hash.from_xml(request)
- parsed_response['RateRequest']['RequestedShipment']['ShipTimestamp'] == timestamp
- end.returns(mock_response)
+ def test_business_days
+ today = DateTime.civil(2013, 3, 12, 0, 0, 0, "-4")
- destination = ActiveMerchant::Shipping::Location.from(@locations[:beverly_hills].to_hash, :address_type => :commercial)
- response = @carrier.find_rates @locations[:ottawa], destination, @packages[:book], :test => true
- assert_equal [delivery_date, delivery_date], response.rates.first.delivery_range
+ Timecop.freeze(today) do
+ assert_equal DateTime.civil(2013, 3, 13, 0, 0, 0, "-4"), @carrier.send(:business_days_from, today, 1)
+ assert_equal DateTime.civil(2013, 3, 15, 0, 0, 0, "-4"), @carrier.send(:business_days_from, today, 3)
+ assert_equal DateTime.civil(2013, 3, 19, 0, 0, 0, "-4"), @carrier.send(:business_days_from, today, 5)
end
end
- def test_turn_around_time_default_handles_weekends
+ def test_turn_around_time_default
mock_response = xml_fixture('fedex/ottawa_to_beverly_hills_rate_response').gsub('<v6:DeliveryTimestamp>2011-07-29</v6:DeliveryTimestamp>', '')
- Timecop.freeze(DateTime.new(2012, 6, 15)) do
+
+ today = DateTime.civil(2013, 3, 11, 0, 0, 0, "-4")
+
+ Timecop.freeze(today) do
delivery_date = Date.today + 7.days # FIVE_DAYS in fixture response, plus weekend
timestamp = Time.now.iso8601
@carrier.expects(:commit).with do |request|
@@ -63,17 +60,6 @@ def test_turn_around_time
assert_equal [delivery_date, delivery_date], response.rates.first.delivery_range
end
end
-
- # def test_no_rates_response
- # @carrier.expects(:commit).returns(xml_fixture('fedex/empty_response'))
- #
- # response = @carrier.find_rates(
- # @locations[:ottawa],
- # @locations[:beverly_hills],
- # @packages.values_at(:book, :wii)
- # )
- # assert_equal "WARNING - 556: There are no valid services available. ", response.message
- # end
def test_find_tracking_info_should_return_a_tracking_response
@carrier.expects(:commit).returns(@tracking_response)

0 comments on commit 23d7d2d

Please sign in to comment.
Something went wrong with that request. Please try again.