Sha256: 181407b2abe69b7ae0e5990a4ca2c202973f60e5abe75adef91f685930717eb2

Contents?: true

Size: 1001 Bytes

Versions: 48

Compression:

Stored size: 1001 Bytes

Contents

# frozen_string_literal: true

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

FactoryBot.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, evaluator|
      shipping_method = evaluator.shipping_method || create(:shipping_method, cost: evaluator.cost)
      shipment.shipping_rates.create!(
        shipping_method: shipping_method,
        cost: evaluator.cost,
        selected: true
      )

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

Version data entries

48 entries across 48 versions & 2 rubygems

Version Path
solidus_core-2.10.5 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.11.3 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.11.2 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.11.1 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.10.3 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.11.0 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.10.2 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.9.6 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.8.6 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.10.1 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.9.5 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.10.0 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.9.4 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.6.6 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.7.4 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.8.5 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.9.3 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.9.2 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.10.0.beta1 lib/spree/testing_support/factories/shipment_factory.rb
solidus_core-2.7.3 lib/spree/testing_support/factories/shipment_factory.rb