Sha256: 7422411610cca316cc6b462cd295cc44be6737b93304465a29840553addbda58

Contents?: true

Size: 1.07 KB

Versions: 23

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
  Spree::TestingSupport::FactoryBot.deprecate_cherry_picking

  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'
end

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

    association :variant, strategy: :create
    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

23 entries across 23 versions & 1 rubygems

Version Path
solidus_core-3.4.6 lib/spree/testing_support/factories/inventory_unit_factory.rb
solidus_core-3.4.5 lib/spree/testing_support/factories/inventory_unit_factory.rb
solidus_core-3.4.4 lib/spree/testing_support/factories/inventory_unit_factory.rb
solidus_core-3.3.4 lib/spree/testing_support/factories/inventory_unit_factory.rb
solidus_core-3.2.9 lib/spree/testing_support/factories/inventory_unit_factory.rb
solidus_core-3.2.8 lib/spree/testing_support/factories/inventory_unit_factory.rb
solidus_core-3.3.3 lib/spree/testing_support/factories/inventory_unit_factory.rb
solidus_core-3.4.3 lib/spree/testing_support/factories/inventory_unit_factory.rb
solidus_core-3.4.2 lib/spree/testing_support/factories/inventory_unit_factory.rb
solidus_core-3.2.7 lib/spree/testing_support/factories/inventory_unit_factory.rb
solidus_core-3.3.2 lib/spree/testing_support/factories/inventory_unit_factory.rb
solidus_core-3.4.1 lib/spree/testing_support/factories/inventory_unit_factory.rb
solidus_core-3.4.0 lib/spree/testing_support/factories/inventory_unit_factory.rb
solidus_core-3.3.1 lib/spree/testing_support/factories/inventory_unit_factory.rb
solidus_core-3.2.6 lib/spree/testing_support/factories/inventory_unit_factory.rb
solidus_core-3.3.0 lib/spree/testing_support/factories/inventory_unit_factory.rb
solidus_core-3.2.5 lib/spree/testing_support/factories/inventory_unit_factory.rb
solidus_core-3.2.4 lib/spree/testing_support/factories/inventory_unit_factory.rb
solidus_core-3.2.3 lib/spree/testing_support/factories/inventory_unit_factory.rb
solidus_core-3.2.2 lib/spree/testing_support/factories/inventory_unit_factory.rb