1
0
Fork 0
mirror of https://github.com/endofunky/sidetiq.git synced 2022-11-09 13:53:30 -05:00

Make config.utc actually work

Fixes #76.
This commit is contained in:
Gabriel Gilder 2014-03-28 15:37:31 -07:00
parent d460e6b991
commit 3ad47c4c89
3 changed files with 12 additions and 3 deletions

View file

@ -9,10 +9,12 @@ module Sidetiq
# Public: Start time offset from epoch used for calculating run
# times in the Sidetiq schedules.
START_TIME = Sidetiq.config.utc ? Time.utc(2010, 1, 1) : Time.local(2010, 1, 1)
def self.start_time
Sidetiq.config.utc ? Time.utc(2010, 1, 1) : Time.local(2010, 1, 1)
end
def initialize # :nodoc:
@schedule = IceCube::Schedule.new(START_TIME)
@schedule = IceCube::Schedule.new(self.class.start_time)
end
def method_missing(meth, *args, &block) # :nodoc:

View file

@ -19,7 +19,7 @@ class TestClock < Sidetiq::TestCase
def test_backfilling
BackfillWorker.jobs.clear
Sidetiq.stubs(:workers).returns([BackfillWorker])
start = Sidetiq::Schedule::START_TIME
start = Sidetiq::Schedule.start_time
BackfillWorker.stubs(:last_scheduled_occurrence).returns(start.to_f)
clock.stubs(:gettime).returns(start)

View file

@ -34,5 +34,12 @@ class TestSchedule < Sidetiq::TestCase
sched.set_options(backfill: false)
refute sched.backfill?
end
def test_use_utc
Sidetiq.config.utc = true
assert_equal(Time.utc(2010, 01, 01), Sidetiq::Schedule.new.start_time)
ensure
Sidetiq.config.utc = false
end
end