Add ability to define minimal time between job executions to support multiple corno nodes, so two different nodes will not execute the same job

This commit is contained in:
avi_alima
2015-08-19 18:08:48 +03:00
parent f76dff32e4
commit 32bdba3244
6 changed files with 61 additions and 4 deletions

View File

@@ -5,4 +5,17 @@ describe Crono::PerformerProxy do
expect(Crono.scheduler).to receive(:add_job).with(kind_of(Crono::Job))
Crono.perform(TestJob).every(2.days, at: '15:30')
end
it 'should set execution interval' do
allow(Crono).to receive(:scheduler).and_return(Crono::Scheduler.new)
expect_any_instance_of(Crono::Job).to receive(:execution_interval=).with(0.minutes).once
expect_any_instance_of(Crono::Job).to receive(:execution_interval=).with(10.minutes).once
Crono.perform(TestJob).every(2.days, at: '15:30').once_per 10.minutes
end
it 'do nothing when job not initalized' do
expect_any_instance_of(Crono::Job).not_to receive(:execution_interval=)
expect_any_instance_of(described_class).to receive(:once_per)
Crono.perform(TestJob).once_per 10.minutes
end
end