Skip to content

Commit

Permalink
Merge pull request #321 from dnd/worker_strategy_options
Browse files Browse the repository at this point in the history
Allow worker strategies to receive import options
  • Loading branch information
pyromaniac committed Jan 28, 2016
2 parents 020b2c3 + b761254 commit 611348e
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/chewy/strategy/active_job.rb
Expand Up @@ -13,8 +13,8 @@ class ActiveJob < Atomic
class Worker < ::ActiveJob::Base
queue_as :chewy

def perform(type, ids)
type.constantize.import!(ids)
def perform(type, ids, options = {})
type.constantize.import!(ids, options)
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/chewy/strategy/resque.rb
Expand Up @@ -13,8 +13,8 @@ class Resque < Atomic
class Worker
@queue = :chewy

def self.perform(type, ids)
type.constantize.import!(ids)
def self.perform(type, ids, options = {})
type.constantize.import!(ids, options)
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/chewy/strategy/sidekiq.rb
Expand Up @@ -13,8 +13,8 @@ class Sidekiq < Atomic
class Worker
include ::Sidekiq::Worker

def perform(type, ids)
type.constantize.import!(ids)
def perform(type, ids, options = {})
type.constantize.import!(ids, options)
end
end

Expand Down
5 changes: 5 additions & 0 deletions spec/chewy/strategy/active_job_spec.rb
Expand Up @@ -45,5 +45,10 @@
.to update_index(CitiesIndex::City, strategy: :active_job)
.and_reindex(city, other_city)
end

specify do
expect(CitiesIndex::City).to receive(:import!).with([city.id, other_city.id], {suffix: '201601'})
Chewy::Strategy::ActiveJob::Worker.new.perform("CitiesIndex::City", [city.id, other_city.id], suffix: '201601')
end
end
end
5 changes: 5 additions & 0 deletions spec/chewy/strategy/resque_spec.rb
Expand Up @@ -31,5 +31,10 @@
.and_reindex(city, other_city)
end
end

specify do
expect(CitiesIndex::City).to receive(:import!).with([city.id, other_city.id], {suffix: '201601'})
Chewy::Strategy::Resque::Worker.perform("CitiesIndex::City", [city.id, other_city.id], suffix: '201601')
end
end
end
5 changes: 5 additions & 0 deletions spec/chewy/strategy/sidekiq_spec.rb
Expand Up @@ -31,5 +31,10 @@
.and_reindex(city, other_city)
end
end

specify do
expect(CitiesIndex::City).to receive(:import!).with([city.id, other_city.id], {suffix: '201601'})
Chewy::Strategy::Sidekiq::Worker.new.perform("CitiesIndex::City", [city.id, other_city.id], suffix: '201601')
end
end
end

0 comments on commit 611348e

Please sign in to comment.