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.9.6 lib/spree/testing_support/factories/stock_package_factory.rb
solidus_core-2.8.6 lib/spree/testing_support/factories/stock_package_factory.rb
solidus_core-2.9.5 lib/spree/testing_support/factories/stock_package_factory.rb
solidus_core-2.9.4 lib/spree/testing_support/factories/stock_package_factory.rb
solidus_core-2.6.6 lib/spree/testing_support/factories/stock_package_factory.rb
solidus_core-2.7.4 lib/spree/testing_support/factories/stock_package_factory.rb
solidus_core-2.8.5 lib/spree/testing_support/factories/stock_package_factory.rb
solidus_core-2.9.3 lib/spree/testing_support/factories/stock_package_factory.rb
solidus_core-2.9.2 lib/spree/testing_support/factories/stock_package_factory.rb
solidus_core-2.10.0.beta1 lib/spree/testing_support/factories/stock_package_factory.rb
solidus_core-2.7.3 lib/spree/testing_support/factories/stock_package_factory.rb
solidus_core-2.6.5 lib/spree/testing_support/factories/stock_package_factory.rb
solidus_core-2.9.1 lib/spree/testing_support/factories/stock_package_factory.rb
solidus_core-2.9.0 lib/spree/testing_support/factories/stock_package_factory.rb
solidus_core-2.9.0.rc.1 lib/spree/testing_support/factories/stock_package_factory.rb
solidus_core-2.8.4 lib/spree/testing_support/factories/stock_package_factory.rb
solidus_core-2.8.3 lib/spree/testing_support/factories/stock_package_factory.rb
solidus_core-2.7.2 lib/spree/testing_support/factories/stock_package_factory.rb
solidus_core-2.6.4 lib/spree/testing_support/factories/stock_package_factory.rb
solidus_core-2.8.2 lib/spree/testing_support/factories/stock_package_factory.rb