Sha256: 453eb77370cfb9a43896c6bce9553fb4f3dd46bc40097a46d797677b9d7f970b

Contents?: true

Size: 768 Bytes

Versions: 43

Compression:

Stored size: 768 Bytes

Contents

# frozen_string_literal: true

require 'spree/testing_support/factories/inventory_unit_factory'
require 'spree/testing_support/factories/variant_factory'

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: variant)
      end
    end

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

Version data entries

43 entries across 43 versions & 2 rubygems

Version Path
solidus_core-2.6.1 lib/spree/testing_support/factories/stock_package_factory.rb
solidus_core-2.6.0 lib/spree/testing_support/factories/stock_package_factory.rb
solidus_core-2.6.0.rc1 lib/spree/testing_support/factories/stock_package_factory.rb