Skip to content
This repository has been archived by the owner on Oct 19, 2018. It is now read-only.

Allow ability to have different times between local and server #13

Open
comexpressao opened this issue Apr 18, 2018 · 0 comments
Open

Comments

@comexpressao
Copy link

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
  end
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant