diff --git a/app/services/line_item_syncer.rb b/app/services/line_item_syncer.rb index 5cff5a5688..bd43827e29 100644 --- a/app/services/line_item_syncer.rb +++ b/app/services/line_item_syncer.rb @@ -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 diff --git a/spec/services/order_syncer_spec.rb b/spec/services/order_syncer_spec.rb index 86cad86a44..67d7937467 100644 --- a/spec/services/order_syncer_spec.rb +++ b/spec/services/order_syncer_spec.rb @@ -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