mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-04 07:09:14 +00:00
Handle case of BackorderJob having no work
This commit is contained in:
@@ -40,6 +40,8 @@ class BackorderJob < ApplicationJob
|
||||
user = order.distributor.owner
|
||||
items = backorderable_items(order)
|
||||
|
||||
return if items.empty?
|
||||
|
||||
# We are assuming that all variants are linked to the same wholesale
|
||||
# shop and its catalog:
|
||||
reference_link = items[0].variant.semantic_links[0].semantic_id
|
||||
|
||||
@@ -104,6 +104,14 @@ RSpec.describe BackorderJob do
|
||||
# Clean up after ourselves:
|
||||
perform_enqueued_jobs(only: CompleteBackorderJob)
|
||||
end
|
||||
|
||||
it "succeeds when no work to be done" do
|
||||
# The database can change before the job is run. So maybe there's nothing
|
||||
# to do.
|
||||
expect {
|
||||
subject.place_backorder(order)
|
||||
}.not_to raise_error
|
||||
end
|
||||
end
|
||||
|
||||
describe "#place_order" do
|
||||
|
||||
Reference in New Issue
Block a user