Sha256: 8c4562cf67e001b86132d53790c6a78b67850855bf7473a23aedb41cf929c499
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
# frozen_string_literal: true require 'rails_helper' module Spree module Stock RSpec.describe InventoryUnitsFinalizer, type: :model do let(:order) { build(:order_with_line_items) } let(:inventory_unit) { build(:inventory_unit, order: order, variant: order.line_items.first.variant, shipment: order.shipments.first) } let(:stock_item) { inventory_unit.variant.stock_items.first } before do stock_item.set_count_on_hand(10) stock_item.update_attributes!(backorderable: false) inventory_unit.update_attributes!(pending: true) end subject { described_class.new([inventory_unit]).run! } it "updates the associated inventory units" do inventory_unit.update_columns(updated_at: 1.hour.ago) expect { subject }.to change { inventory_unit.reload.updated_at } end it "updates the inventory units to not be pending" do expect { subject }.to change { inventory_unit.reload.pending }.to(false) end it "unstocks the variant" do expect { subject }.to change { stock_item.reload.count_on_hand }.from(10).to(9) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
solidus_core-2.8.0 | spec/models/spree/stock/inventory_units_finalizer_spec.rb |