Skip to content

Commit

Permalink
Fix compatibility with Global ID (#1064)
Browse files Browse the repository at this point in the history
  • Loading branch information
bensheldon authored Sep 2, 2023
1 parent f6e8270 commit 1ee5368
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/models/good_job/batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ def self.enqueue(active_jobs = [], **properties, &block)
end
end

def self.primary_key
:id
end

def self.find(id)
new _record: BatchRecord.find(id)
end
Expand Down
10 changes: 10 additions & 0 deletions spec/app/models/good_job/batch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ def perform(batch, params)
end)
end

it 'is a valid GlobalId' do
batch = described_class.new
batch.save

global_id = batch.to_global_id
returned_batch = GlobalID::Locator.locate(global_id)

expect(returned_batch.id).to eq batch.id
end

describe '.enqueue' do
it 'creates a batch' do
batch = described_class.enqueue do
Expand Down

0 comments on commit 1ee5368

Please sign in to comment.