Fix typo and add test case to cover out of stock case

This commit is contained in:
luisramos0
2019-07-16 10:58:25 +01:00
parent 02099ebdae
commit 267131626e
2 changed files with 14 additions and 3 deletions

View File

@@ -78,7 +78,7 @@ class LineItemSyncer
if line_item.variant.in_stock?
I18n.t("admin.subscriptions.stock.insufficient_stock")
else
I18n.t("admin.subscriptions.stock..out_of_stock")
I18n.t("admin.subscriptions.stock.out_of_stock")
end
end
end

View File

@@ -407,9 +407,9 @@ describe OrderSyncer do
end
context "when order is complete" do
before { AdvanceOrderService.new(order).call }
it "does not update the line_item quantities and adds the order to order_update_issues with insufficient stock" do
AdvanceOrderService.new(order).call
it "does not update the line_item quantities and adds the order to order_update_issues" do
expect(syncer.sync!).to be true
line_items = Spree::LineItem.where(order_id: subscription.orders, variant_id: sli.variant_id)
@@ -418,6 +418,17 @@ describe OrderSyncer do
line_item = order.line_items.find_by_variant_id(sli.variant_id)
expect(syncer.order_update_issues[order.id]).to include "#{line_item.product.name} - #{line_item.variant.full_name} - Insufficient stock available"
end
it "does not update the line_item quantities and adds the order to order_update_issues with out of stock" do
# this single item available is used when the order is completed below, making the item out of stock
variant.update_attribute(:on_hand, 1)
AdvanceOrderService.new(order).call
expect(syncer.sync!).to be true
line_item = order.line_items.find_by_variant_id(sli.variant_id)
expect(syncer.order_update_issues[order.id]).to include "#{line_item.product.name} - #{line_item.variant.full_name} - Out of Stock"
end
end
end