Handle case of BackorderJob having no work

This commit is contained in:
Maikel Linke
2024-10-17 15:39:32 +11:00
parent 197363b199
commit 9c7105e764
2 changed files with 10 additions and 0 deletions

View File

@@ -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

View File

@@ -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