Sha256: 274f3b8d5881e0ebcb8dd88a74ef8a848f2cd41770a4fba88ebc606fc7b65a10

Contents?: true

Size: 1.04 KB

Versions: 56

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

require 'spree/testing_support/factory_bot'
Spree::TestingSupport::FactoryBot.when_cherry_picked do
  Spree::TestingSupport::FactoryBot.deprecate_cherry_picking

  require 'spree/testing_support/factories/inventory_unit_factory'
  require 'spree/testing_support/factories/return_reason_factory'
  require 'spree/testing_support/factories/return_authorization_factory'
end

FactoryBot.define do
  factory :return_item, class: 'Spree::ReturnItem' do
    association(:inventory_unit, factory: :inventory_unit, state: :shipped)
    association(:return_reason, factory: :return_reason)
    return_authorization do |_return_item|
      build(:return_authorization, order: inventory_unit.order)
    end

    factory :exchange_return_item do
      after(:build) do |return_item|
        # set track_inventory to false to ensure it passes the in_stock check
        return_item.inventory_unit.variant.update_column(:track_inventory, false)
        return_item.exchange_variant = return_item.inventory_unit.variant
      end
    end
  end
end

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
solidus_core-3.4.6 lib/spree/testing_support/factories/return_item_factory.rb
solidus_core-3.4.5 lib/spree/testing_support/factories/return_item_factory.rb
solidus_core-3.4.4 lib/spree/testing_support/factories/return_item_factory.rb
solidus_core-3.3.4 lib/spree/testing_support/factories/return_item_factory.rb
solidus_core-3.2.9 lib/spree/testing_support/factories/return_item_factory.rb
solidus_core-3.2.8 lib/spree/testing_support/factories/return_item_factory.rb
solidus_core-3.3.3 lib/spree/testing_support/factories/return_item_factory.rb
solidus_core-3.4.3 lib/spree/testing_support/factories/return_item_factory.rb
solidus_core-3.4.2 lib/spree/testing_support/factories/return_item_factory.rb
solidus_core-3.2.7 lib/spree/testing_support/factories/return_item_factory.rb
solidus_core-3.3.2 lib/spree/testing_support/factories/return_item_factory.rb
solidus_core-3.4.1 lib/spree/testing_support/factories/return_item_factory.rb
solidus_core-3.4.0 lib/spree/testing_support/factories/return_item_factory.rb
solidus_core-3.3.1 lib/spree/testing_support/factories/return_item_factory.rb
solidus_core-3.2.6 lib/spree/testing_support/factories/return_item_factory.rb
solidus_core-3.1.9 lib/spree/testing_support/factories/return_item_factory.rb
solidus_core-3.3.0 lib/spree/testing_support/factories/return_item_factory.rb
solidus_core-3.2.5 lib/spree/testing_support/factories/return_item_factory.rb
solidus_core-3.2.4 lib/spree/testing_support/factories/return_item_factory.rb
solidus_core-3.2.3 lib/spree/testing_support/factories/return_item_factory.rb