Sha256: a77aa35fc3985c762b8ded5f8ee12e87b206bbf18c04a0a07e425a2c89183437

Contents?: true

Size: 678 Bytes

Versions: 5

Compression:

Stored size: 678 Bytes

Contents

# frozen_string_literal: true

FactoryBot.define do
  factory :stock_package, class: 'Spree::Stock::Package' do
    skip_create

    transient do
      stock_location { build(:stock_location) }
      contents       { [] }
      variants_contents { {} }
    end

    initialize_with { new(stock_location, contents) }

    after(:build) do |package, evaluator|
      evaluator.variants_contents.each do |variant, count|
        package.add_multiple build_list(:inventory_unit, count, variant:, stock_location: evaluator.stock_location)
      end
    end

    factory :stock_package_fulfilled do
      transient { variants_contents { { build(:variant) => 2 } } }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
solidus_core-4.5.1 lib/spree/testing_support/factories/stock_package_factory.rb
solidus_core-4.5.0 lib/spree/testing_support/factories/stock_package_factory.rb
solidus_core-4.4.2 lib/spree/testing_support/factories/stock_package_factory.rb
solidus_core-4.4.1 lib/spree/testing_support/factories/stock_package_factory.rb
solidus_core-4.4.0 lib/spree/testing_support/factories/stock_package_factory.rb