spec/scheduler_spec.rb in rufus-scheduler-3.1.1 vs spec/scheduler_spec.rb in rufus-scheduler-3.1.2

- old
+ new

@@ -609,11 +609,11 @@ expect(h[j0].size).to eq(6) end end - describe '#timeline(time0, time1)' do + describe '#timeline' do it 'returns a [ [ time, job ], ... ] of job occurrences' do j0 = @scheduler.schedule_in '5m' do; end j1 = @scheduler.schedule_in '10m' do; end @@ -622,9 +622,24 @@ expect(a[0][0]).to be_within_1s_of(Time.now + 5 * 60) expect(a[0][1]).to eq(j0) expect(a[1][0]).to be_within_1s_of(Time.now + 10 * 60) expect(a[1][1]).to eq(j1) + end + + it 'should not lock when running timeline with a :first_at specified' do + + now = Time.now + + # scheduling a cron job with a first_at and running #timeline used + # to result in an infinite loop. + + @scheduler.cron('* * * * * *', :first_at => now + 3) {} + + jobs = @scheduler.timeline(now, now + 4) + expect(jobs.size).to be 2 + expect(jobs[0][0]).to be_within_1s_of now + 3 + expect(jobs[1][0]).to be_within_1s_of now + 4 end end #-- # management methods