Sha256: b81c36ca1291787d17668731a5d4674c0e2d8d2e751a63c23526d357628cb959

Contents?: true

Size: 975 Bytes

Versions: 2

Compression:

Stored size: 975 Bytes

Contents

require 'test_helper'

module Workarea
  class UpdateKitInventoryTest < TestCase
    def test_perform
      product = create_product(
        variants: [{
            sku: 'SKU',
            components: [
              { sku: 'BSKU1', quantity: 1 },
              { sku: 'BSKU2', quantity: 2 },
            ]
        }]
      )

      UpdateKitInventory
        .new
        .perform(product.id.to_s, product.variants.first.id.to_s)

      inventory = Inventory::Sku.find('SKU')
      assert_equal({ 'BSKU1' => 1, 'BSKU2' => 2 }, inventory.component_quantities)

      product.variants.first.update!(
        components: [
          { sku: 'BSKU1', quantity: 2 },
          { sku: 'BSKU2', quantity: 4 },
        ]
      )

      UpdateKitInventory
        .new
        .perform(product.id.to_s, product.variants.first.id.to_s)

      inventory = Inventory::Sku.find('SKU')
      assert_equal({ 'BSKU1' => 2, 'BSKU2' => 4 }, inventory.component_quantities)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
workarea-product_bundles-1.0.1 test/workers/workarea/update_kit_inventory_test.rb
workarea-product_bundles-1.0.0 test/workers/workarea/update_kit_inventory_test.rb