Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin updates can trigger new backorders until the order cycle is closed #13065

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/services/backorder_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def amend_backorder(order)

backorder = orderer.find_open_order(order)

update(backorder, user, distributor, order_cycle)
update(backorder, user, distributor, order_cycle) if backorder
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it amounts to the same thing, but I thought that we usually avoid implied booleans and use the more explicit present?

But i'm sure it amounts to the same thing, and this looks cleaner so I like it :)

end

# Update a given backorder according to a distributor's order cycle.
Expand Down
7 changes: 7 additions & 0 deletions spec/services/backorder_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@
.to change { backorder.lines.count }.from(2).to(1)
.and change { beans.reload.on_hand }.by(-12)
end

it "skips updating if there's is no backorder" do
allow_any_instance_of(FdcBackorderer).to receive(:find_open_order)
.and_return(nil)

expect { subject.amend_backorder(order) }.not_to raise_error
end
end

describe "#distributed_linked_variants" do
Expand Down