Skip to content

Commit

Permalink
Merge pull request #41 from skisulli/add-unique-key-to-message
Browse files Browse the repository at this point in the history
Add the unique hash to the message for use by the workers.
  • Loading branch information
mhenrixon committed Jun 8, 2014
2 parents b347577 + 22c358f commit 15c2142
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/sidekiq-unique-jobs/middleware/client/unique_jobs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def call(worker_class, item, queue, redis_pool = nil)
@item = item

if unique_enabled?
@item['unique_hash'] = payload_hash
yield if unique?
else
yield
Expand Down
8 changes: 8 additions & 0 deletions spec/lib/sidekiq_testing_enabled_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
UniqueWorker.perform_async(param)
expect(UniqueWorker.jobs.size).to eq(1)
end

it "adds the unique_hash to the message" do
param = 'hash'
hash = SidekiqUniqueJobs::PayloadHelper.get_payload(UniqueWorker, :working, [param])
UniqueWorker.perform_async(param)
expect(UniqueWorker.jobs.size).to eq(1)
expect(UniqueWorker.jobs.first['unique_hash']).to eq(hash)
end
end

context "with non-unique worker" do
Expand Down

0 comments on commit 15c2142

Please sign in to comment.