Skip to content

Commit

Permalink
Fix Resque::Scheduler.print_schedule
Browse files Browse the repository at this point in the history
Added in 893f13c, this is intended to help with debugging. The `:t` and `:last` attrs were removed in the jmettraux/rufus-scheduler@v2.0.24...v3.0.0

It seems `#print_schedule` likely hasn't worked since the `rufus-scheduler` depenency was bumped to require ~3.0 in d24657e#diff-9732d81ad66d6656923a3883e83f6620a3b16a07484745677a0776f6e0bff025.

This fixes the `OpenStruct` warnings seen in tests for newer Ruby versions.
  • Loading branch information
codealchemy committed Dec 30, 2024
1 parent 496f086 commit f336a82
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/resque/scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def print_schedule
if rufus_scheduler
log! "Scheduling Info\tLast Run"
scheduler_jobs = rufus_scheduler.jobs
scheduler_jobs.each do |_k, v|
log! "#{v.t}\t#{v.last}\t"
scheduler_jobs.each do |job|
log! "#{job.opts}\t#{job.last_time}\t"
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions test/scheduler_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -589,15 +589,15 @@ def enqueue_started!

context 'printing schedule' do
setup do
Resque::Scheduler.expects(:log!).at_least_once
Resque::Scheduler.stubs(:log!)
end

test 'prints schedule' do
fake_rufus_scheduler = mock
fake_rufus_scheduler.expects(:jobs).at_least_once
.returns(foo: OpenStruct.new(t: nil, last: nil))
Resque::Scheduler.expects(:rufus_scheduler).at_least_once
.returns(fake_rufus_scheduler)
rufus_scheduler = Rufus::Scheduler.new
fake_job = rufus_scheduler.at(Time.now + 1, job: true) {}
Resque::Scheduler.expects(:rufus_scheduler).at_least_once.returns(rufus_scheduler)
Resque::Scheduler.expects(:log!).with("#{fake_job.opts}\t#{fake_job.last_time}\t")

Resque::Scheduler.print_schedule
end
end
Expand Down

0 comments on commit f336a82

Please sign in to comment.