Skip to content

Commit

Permalink
Rubocop changes
Browse files Browse the repository at this point in the history
* Spacing, double quotes

* Support Ruby < 3.2 by removing the implicit key/variable syntax
  • Loading branch information
jpcamara committed Sep 9, 2024
1 parent fa64e45 commit 4a0bf92
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions app/models/solid_queue/job_batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def enqueue(attributes = {})
def dispatch_finished_batches
incomplete.order(:id).pluck(:id).each do |id|
transaction do
where(id:).non_blocking_lock.each(&:finish)
where(id: id).non_blocking_lock.each(&:finish)
end
end
end
Expand Down Expand Up @@ -82,8 +82,8 @@ def finish
if on_finish_active_job.present?
active_job = ActiveJob::Base.deserialize(on_finish_active_job)
active_job.send(:deserialize_arguments_if_needed)
active_job.arguments = [self] + Array.wrap(active_job.arguments)
ActiveJob.perform_all_later([active_job])
active_job.arguments = [ self ] + Array.wrap(active_job.arguments)
ActiveJob.perform_all_later([ active_job ])
attrs[:job] = Job.find_by(active_job_id: active_job.job_id)
end

Expand Down
4 changes: 2 additions & 2 deletions lib/active_job/job_batch_id.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ module JobBatchId
end

def serialize
super.merge('batch_id' => batch_id)
super.merge("batch_id" => batch_id)
end

def deserialize(job_data)
super
self.batch_id = job_data['batch_id']
self.batch_id = job_data["batch_id"]
end

def batch
Expand Down
8 changes: 4 additions & 4 deletions test/models/solid_queue/job_batch_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ def perform(arg)
end

test "batch will be completed on success" do
batch = SolidQueue::JobBatch.enqueue(on_finish: BatchCompletionJob) {}
batch = SolidQueue::JobBatch.enqueue(on_finish: BatchCompletionJob) { }
assert_not_nil batch.on_finish_active_job
assert_equal BatchCompletionJob.name, batch.on_finish_active_job["job_class"]
end

test "batch will be completed on finish" do
batch = SolidQueue::JobBatch.enqueue(on_success: BatchCompletionJob) {}
batch = SolidQueue::JobBatch.enqueue(on_success: BatchCompletionJob) { }
assert_not_nil batch.on_success_active_job
assert_equal BatchCompletionJob.name, batch.on_success_active_job["job_class"]
end
Expand All @@ -41,7 +41,7 @@ def perform(arg)
end

assert_equal 2, SolidQueue::Job.count
assert_equal [batch.id] * 2, SolidQueue::Job.last(2).map(&:batch_id)
assert_equal [ batch.id ] * 2, SolidQueue::Job.last(2).map(&:batch_id)
end

test "batch id is present inside the block" do
Expand All @@ -60,7 +60,7 @@ def perform(arg)
end

assert_not_nil SolidQueue::JobBatch.last.on_finish_active_job["arguments"]
assert_equal SolidQueue::JobBatch.last.on_finish_active_job["arguments"], [1, 2]
assert_equal SolidQueue::JobBatch.last.on_finish_active_job["arguments"], [ 1, 2 ]
assert_equal SolidQueue::JobBatch.last.on_finish_active_job["queue_name"], "batch"
end
end

0 comments on commit 4a0bf92

Please sign in to comment.