Skip to content

Commit

Permalink
Support interval schedule type
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
snmgian committed Apr 18, 2016
1 parent 4cd22fd commit 85a4c95
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/sidekiq/scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def self.load_schedule_job(name, config)
if config['rails_env'].nil? || self.rails_env_matches?(config)
logger.info "Scheduling #{name} #{config}"
interval_defined = false
interval_types = %w{cron every at in}
interval_types = %w{cron every at in interval}
interval_types.each do |interval_type|
if !config[interval_type].nil? && config[interval_type].length > 0
args = self.optionizate_interval_value(config[interval_type])
Expand Down
9 changes: 9 additions & 0 deletions spec/sidekiq/scheduler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,15 @@
end
end

context 'interval schedule' do
it 'loads correctly' do
Sidekiq::Scheduler.load_schedule_job('some_job', ScheduleFaker.interval_schedule)

expect(Sidekiq::Scheduler.rufus_scheduler.jobs.size).to be(1)
expect(Sidekiq::Scheduler.scheduled_jobs.keys).to eq(%w(some_job))
end
end

it 'does not load without a timing option' do
Sidekiq::Scheduler.load_schedule_job('some_job', ScheduleFaker.invalid_schedule)

Expand Down
6 changes: 6 additions & 0 deletions spec/support/faker/schedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ def self.in_schedule(options = {})
}.merge(default_options(options))
end

def self.interval_schedule(options = {})
options = {
'interval' => '5m'
}.merge(default_options(options))
end

def self.invalid_schedule(options = {})
default_options(options)
end
Expand Down

0 comments on commit 85a4c95

Please sign in to comment.