Sha256: 3f38d70cffd3d58a20c5b0f98fe87d57fb4701fd580136dd8865dbc21fc8349e

Contents?: true

Size: 809 Bytes

Versions: 12

Compression:

Stored size: 809 Bytes

Contents

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

    initialize_with { new(stock_location, contents) }
  end

  factory :stock_package, class: Spree::Stock::Package do
    ignore 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

12 entries across 12 versions & 1 rubygems

Version Path
spree_core-2.3.4 lib/spree/testing_support/factories/stock_factory.rb
spree_core-2.2.6 lib/spree/testing_support/factories/stock_factory.rb
spree_core-2.3.3 lib/spree/testing_support/factories/stock_factory.rb
spree_core-2.3.2 lib/spree/testing_support/factories/stock_factory.rb
spree_core-2.2.5 lib/spree/testing_support/factories/stock_factory.rb
spree_core-2.3.1 lib/spree/testing_support/factories/stock_factory.rb
spree_core-2.2.4 lib/spree/testing_support/factories/stock_factory.rb
spree_core-2.2.3 lib/spree/testing_support/factories/stock_factory.rb
spree_core-2.3.0 lib/spree/testing_support/factories/stock_factory.rb
spree_core-2.2.2 lib/spree/testing_support/factories/stock_factory.rb
spree_core-2.2.1 lib/spree/testing_support/factories/stock_factory.rb
spree_core-2.2.0 lib/spree/testing_support/factories/stock_factory.rb