Skip to content

Commit

Permalink
Fix metadata for Sidekiq strict_args!
Browse files Browse the repository at this point in the history
- update `scheduled_at` metadata to string key, hash rocket syntax
- update spec to expect string key, hash rocket syntax
  • Loading branch information
craigmcn authored and marcelolx committed Sep 6, 2022
1 parent 8b19a25 commit ecb35ae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/sidekiq-scheduler/scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def enqueue_job(job_config, time = Time.now)
config = prepare_arguments(job_config.dup)

if config.delete('include_metadata')
config['args'] = arguments_with_metadata(config['args'], scheduled_at: time.to_f)
config['args'] = arguments_with_metadata(config['args'], "scheduled_at" => time.to_f)
end

if SidekiqScheduler::Utils.active_job_enqueue?(config['class'])
Expand Down
10 changes: 5 additions & 5 deletions spec/sidekiq-scheduler/scheduler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
expect(Sidekiq::Client).to receive(:push).with(
'class' => SomeWorker,
'queue' => 'high',
'args' => ['/tmp', { scheduled_at: schedule_time.to_f }]
'args' => ['/tmp', { 'scheduled_at' => schedule_time.to_f }]
)

subject
Expand All @@ -203,7 +203,7 @@
expect(Sidekiq::Client).to receive(:push).with(
'class' => SomeWorker,
'queue' => 'high',
'args' => ['/tmp', { scheduled_at: schedule_time.to_f }]
'args' => ['/tmp', { 'scheduled_at' => schedule_time.to_f }]
)

subject
Expand All @@ -217,7 +217,7 @@
it 'enqueues the job as active job' do
expect(EmailSender).to receive(:new).with(
'/tmp',
{ scheduled_at: schedule_time.to_f }
{ 'scheduled_at' => schedule_time.to_f }
).and_return(double(:job).as_null_object)

subject
Expand All @@ -237,7 +237,7 @@
expect(Sidekiq::Client).to receive(:push).with(
'class' => SomeWorker,
'queue' => 'high',
'args' => [{ dir: '/tmp' }, { scheduled_at: schedule_time.to_f }]
'args' => [{ dir: '/tmp' }, { 'scheduled_at' => schedule_time.to_f }]
)

subject
Expand All @@ -253,7 +253,7 @@
expect(Sidekiq::Client).to receive(:push).with(
'class' => SomeWorker,
'queue' => 'high',
'args' => [{ scheduled_at: schedule_time.to_f }]
'args' => [{ 'scheduled_at' => schedule_time.to_f }]
)

subject
Expand Down

0 comments on commit ecb35ae

Please sign in to comment.