This repository was archived by the owner on Oct 19, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Allow ability to have different times between local and server #13
Copy link
Copy link
Open
Description
Had an issue where server time was being used rather than time zone of the app. Below is an example using a combination of Timecop and stubbing that I was able to use to simulate the issue. Could there be a way to set an option in hyper-spec to offset the local vs server time?
context 'calculating delivery at date' do
{ est: Time.parse('2018-04-09 21:00:00 -0400'),
hst: Time.parse('2018-04-09 15:00:00 -10:00') }.each do |time_zone, time|
context "for #{time_zone} location" do
before do
Timecop.freeze(time)
allow(Time).to receive(:now).and_return(Time.now.utc)
end
after { Timecop.return }
# When order is checked out the order is not yet created
it 'should calculate correctly when created at is nil' do
order = FactoryGirl.create(:order)
order.created_at = nil
expect(order.calculate_delivery_at).to eq(Time.parse('2018-04-17'))
end
it 'should calculate correctly with fullfillment' do
order = FactoryGirl.create(:order, :with_fullfillment_job)
expect(order.calculate_delivery_at).to eq(Time.parse('2018-04-19'))
end
it 'should calculate correctly when proofs are approved' do
order = FactoryGirl.create(:order)
expect(order.calculate_delivery_at(true)).to eq(Time.parse('2018-04-17'))
end
end
end
endMetadata
Metadata
Assignees
Labels
No labels