Skip to content

Commit

Permalink
Get the test suite back to green
Browse files Browse the repository at this point in the history
* Fix some mocha and redis deprecation warnings
* Only do strict keyword matching on Mocha for ruby >= 2.7.0
* Only raise on deprecatioin in specs on redis >= 5.0
  • Loading branch information
PatrickTulskie committed Jun 8, 2023
1 parent 32a9c0c commit 0eabeb0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/resque/scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,15 @@ def enqueue_items_in_batch_for_timestamp(timestamp, batch_size)
# be safe as our ltrim is inside the multi block and therefore also would have been
# aborted. So nothing would have been queued, but also nothing lost from the bucket.
watch_result = Resque.redis.watch(timestamp_bucket_key) do
Resque.redis.multi do
Resque.redis.multi do |pipeline|
encoded_jobs_to_requeue.each do |encoded_job|
Resque.redis.srem("timestamps:#{encoded_job}", timestamp_bucket_key)
pipeline.srem("timestamps:#{encoded_job}", timestamp_bucket_key)

decoded_job = Resque.decode(encoded_job)
enqueue(decoded_job)
end

Resque.redis.ltrim(timestamp_bucket_key, batch_size, -1)
pipeline.ltrim(timestamp_bucket_key, batch_size, -1)
end
end

Expand Down
4 changes: 2 additions & 2 deletions test/delayed_queue_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@
test 'calls klass#scheduled when enqueuing jobs if it exists' do
t = Time.now - 60
FakeCustomJobClassEnqueueAt.expects(:scheduled)
.once.with(:test, FakeCustomJobClassEnqueueAt.to_s, foo: 'bar')
.once.with(:test, FakeCustomJobClassEnqueueAt.to_s, { foo: 'bar' })
Resque.enqueue_at(t, FakeCustomJobClassEnqueueAt, foo: 'bar')
end

Expand All @@ -332,7 +332,7 @@
Resque.inline = true
t = Time.now - 60
FakeCustomJobClassEnqueueAt.expects(:scheduled)
.once.with(:test, FakeCustomJobClassEnqueueAt.to_s, foo: 'bar')
.once.with(:test, FakeCustomJobClassEnqueueAt.to_s, { foo: 'bar' })
Resque.enqueue_at(t, FakeCustomJobClassEnqueueAt, foo: 'bar')
ensure
Resque.inline = old_val
Expand Down
4 changes: 2 additions & 2 deletions test/scheduler_args_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
args:
key: value
YAML
SomeIvarJob.expects(:perform).once.with('key' => 'value')
SomeIvarJob.expects(:perform).once.with({ 'key' => 'value' })
Resque.reserve('ivar').perform
end

Expand All @@ -208,7 +208,7 @@
second_key: value
YAML
SomeIvarJob.expects(:perform).once
.with('first_key' => { 'second_key' => 'value' })
.with({ 'first_key' => { 'second_key' => 'value' } })
Resque.reserve('ivar').perform
end

Expand Down
9 changes: 8 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@

# Raise on Redis deprecations if we're using a modern enough version of the Resque gem
if Redis.respond_to?(:'raise_deprecations=')
Redis.raise_deprecations = Gem.loaded_specs['resque'].version >= Gem::Version.create('2.4')
Redis.raise_deprecations = Gem.loaded_specs['resque'].version >= Gem::Version.create('2.4') &&
Gem.loaded_specs['redis'].version >= Gem::Version.create('5.0')
end

if RUBY_VERSION >= '2.7.0'
Mocha.configure do |c|
c.strict_keyword_argument_matching = true
end
end

##
Expand Down

0 comments on commit 0eabeb0

Please sign in to comment.