Sha256: 6d7159373b358c9485529e3a2a0d7e9820a7006f32ac032dc2cd8ef6deac1d07

Contents?: true

Size: 978 Bytes

Versions: 28

Compression:

Stored size: 978 Bytes

Contents

require 'spree/testing_support/factories/order_factory'
require 'spree/testing_support/factories/stock_location_factory'
require 'spree/testing_support/factories/shipping_method_factory'
require 'spree/testing_support/factories/stock_location_factory'

FactoryGirl.define do
  factory :shipment, class: Spree::Shipment do
    tracking 'U10000'
    cost 100.00
    state 'pending'
    order
    stock_location

    transient do
      shipping_method nil
    end

    after(:create) do |shipment, evalulator|
      shipping_method = evalulator.shipping_method || create(:shipping_method, cost: evalulator.cost)
      shipment.add_shipping_method(shipping_method, true)

      shipment.order.line_items.each do |line_item|
        line_item.quantity.times do
          shipment.inventory_units.create!(
            order_id: shipment.order_id,
            variant_id: line_item.variant_id,
            line_item_id: line_item.id
          )
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
solidus_core-2.1.1 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.0.3 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-1.4.2 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-1.3.2 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-1.2.3 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.0.2 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-1.4.1 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.1.0 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.1.0.rc1 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.0.1 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.1.0.beta1 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.0.0 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-1.4.0 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.0.0.rc1 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-1.4.0.rc1 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.0.0.beta1 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-1.4.0.beta1 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-1.3.1 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-1.3.0 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-1.3.0.rc2 lib/spree/testing_support/factories/shipment_factory.rb