diff --git a/lib/open_food_network/products_cache_refreshment.rb b/lib/open_food_network/products_cache_refreshment.rb index 68ed5365c1..276734570f 100644 --- a/lib/open_food_network/products_cache_refreshment.rb +++ b/lib/open_food_network/products_cache_refreshment.rb @@ -41,7 +41,7 @@ module OpenFoodNetwork end def self.enqueue_job(distributor, order_cycle) - Delayed::Job.enqueue RefreshProductsCacheJob.new distributor.id, order_cycle.id + Delayed::Job.enqueue RefreshProductsCacheJob.new(distributor.id, order_cycle.id), priority: 10 end end end diff --git a/spec/lib/open_food_network/products_cache_refreshment_spec.rb b/spec/lib/open_food_network/products_cache_refreshment_spec.rb index bb033cd041..f65b81346e 100644 --- a/spec/lib/open_food_network/products_cache_refreshment_spec.rb +++ b/spec/lib/open_food_network/products_cache_refreshment_spec.rb @@ -13,6 +13,12 @@ module OpenFoodNetwork ProductsCacheRefreshment.refresh distributor, order_cycle end.to enqueue_job RefreshProductsCacheJob end + + it "enqueues the job with a lower than default priority" do + ProductsCacheRefreshment.refresh distributor, order_cycle + job = Delayed::Job.last + expect(job.priority).to be > Delayed::Worker.default_priority + end end describe "when there is an enqueued task, and it is running" do