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

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

@comexpressao

Description

@comexpressao

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions