Sha256: 1da9fc6cc387f62d8423de46dcdc0ef89090cc14507ed70ea2742af8d82353e6

Contents?: true

Size: 892 Bytes

Versions: 9

Compression:

Stored size: 892 Bytes

Contents

# frozen_string_literal: true

require 'spree/testing_support/factories/line_item_factory'
require 'spree/testing_support/factories/variant_factory'
require 'spree/testing_support/factories/order_factory'
require 'spree/testing_support/factories/shipment_factory'

FactoryBot.define do
  factory :inventory_unit, class: 'Spree::InventoryUnit' do
    transient do
      order { nil }
      stock_location { nil }
    end

    variant
    line_item do
      if order
        build(:line_item, variant: variant, order: order)
      else
        build(:line_item, variant: variant)
      end
    end
    state { 'on_hand' }
    shipment do
      if stock_location
        build(:shipment, state: 'pending', order: line_item.order, stock_location: stock_location)
      else
        build(:shipment, state: 'pending', order: line_item.order)
      end
    end
    # return_authorization
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
solidus_core-2.10.5 lib/spree/testing_support/factories/inventory_unit_factory.rb
solidus_core-2.11.3 lib/spree/testing_support/factories/inventory_unit_factory.rb
solidus_core-2.11.2 lib/spree/testing_support/factories/inventory_unit_factory.rb
solidus_core-2.11.1 lib/spree/testing_support/factories/inventory_unit_factory.rb
solidus_core-2.10.3 lib/spree/testing_support/factories/inventory_unit_factory.rb
solidus_core-2.11.0 lib/spree/testing_support/factories/inventory_unit_factory.rb
solidus_core-2.10.2 lib/spree/testing_support/factories/inventory_unit_factory.rb
solidus_core-2.10.1 lib/spree/testing_support/factories/inventory_unit_factory.rb
solidus_core-2.10.0 lib/spree/testing_support/factories/inventory_unit_factory.rb