Skip to content

Commit

Permalink
Merge pull request #12929 from mkllnk/dfc-backorder-fix
Browse files Browse the repository at this point in the history
Handle case of BackorderJob having no work
  • Loading branch information
mkllnk authored Oct 17, 2024
2 parents 783de09 + 9c7105e commit 2609298
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/jobs/backorder_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def place_backorder(order)
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
Expand Down
8 changes: 8 additions & 0 deletions spec/jobs/backorder_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@
# 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
Expand Down

0 comments on commit 2609298

Please sign in to comment.