Skip to content

Commit

Permalink
Add service for creating promotion batch
Browse files Browse the repository at this point in the history
  • Loading branch information
tomdonarski committed Nov 13, 2023
1 parent 01f128d commit 60848a6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/services/create_promotion_batch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class CreatePromotionBatch
def self.call(promotion, size)
size.times do
DuplicatePromotionJob.perform_async(promotion.id)
end
end
end
19 changes: 19 additions & 0 deletions spec/services/create_promotion_batch_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'spec_helper'

describe CreatePromotionBatch do
describe "#call" do
subject(:batch) { described_class.call(promotion, size) }

let(:promotion) { create(:promotion) }
let(:size) { 50 }

it "enqueues DuplicatePromotionJob jobs", sidekiq: :inline do
expect(DuplicatePromotionJob)
.to receive(:perform_async)
.at_least(50).times
.with(promotion.id)

batch
end
end
end

0 comments on commit 60848a6

Please sign in to comment.