Sha256: dfb7d3c3e85cb439e6df638112b6c17f716910cdd498582fbb80b1bf28b2febc

Contents?: true

Size: 815 Bytes

Versions: 17

Compression:

Stored size: 815 Bytes

Contents

FactoryGirl.define do
  # must use build()
  factory :stock_packer, class: Spree::Stock::Packer do
    transient do
      stock_location { build(:stock_location) }
      contents []
    end

    initialize_with { new(stock_location, contents) }
  end

  factory :stock_package, class: Spree::Stock::Package do
    transient do
      stock_location { build(:stock_location) }
      order { create(:order_with_line_items, line_items_count: 2) }
      contents []
    end

    initialize_with { new(stock_location, order, contents) }

    factory :stock_package_fulfilled do
      after(:build) do |package, evaluator|
        evaluator.order.line_items.reload
        evaluator.order.line_items.each do |line_item|
          package.add line_item, line_item.quantity, :on_hand
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
spree_core-2.3.13 lib/spree/testing_support/factories/stock_factory.rb
spree_core-2.2.14 lib/spree/testing_support/factories/stock_factory.rb
spree_core-2.3.12 lib/spree/testing_support/factories/stock_factory.rb
spree_core-2.2.13 lib/spree/testing_support/factories/stock_factory.rb
spree_core-2.3.11 lib/spree/testing_support/factories/stock_factory.rb
spree_core-2.2.12 lib/spree/testing_support/factories/stock_factory.rb
spree_core-2.3.10 lib/spree/testing_support/factories/stock_factory.rb
spree_core-2.3.9 lib/spree/testing_support/factories/stock_factory.rb
spree_core-2.2.11 lib/spree/testing_support/factories/stock_factory.rb
spree_core-2.2.10 lib/spree/testing_support/factories/stock_factory.rb
spree_core-2.3.8 lib/spree/testing_support/factories/stock_factory.rb
spree_core-2.3.7 lib/spree/testing_support/factories/stock_factory.rb
spree_core-2.2.9 lib/spree/testing_support/factories/stock_factory.rb
spree_core-2.3.6 lib/spree/testing_support/factories/stock_factory.rb
spree_core-2.2.8 lib/spree/testing_support/factories/stock_factory.rb
spree_core-2.3.5 lib/spree/testing_support/factories/stock_factory.rb
spree_core-2.2.7 lib/spree/testing_support/factories/stock_factory.rb