Sha256: 01a1b6dc0a39affe153fd31f52c896c5b75cb518e7619a6f6e21b25a58af4e5a

Contents?: true

Size: 1004 Bytes

Versions: 87

Compression:

Stored size: 1004 Bytes

Contents

FactoryGirl.define do

  factory :customer_return, class: Spree::CustomerReturn do
    association(:stock_location, factory: :stock_location)

    transient do
      line_items_count 1
      return_items_count { line_items_count }
    end

    before(:create) do |customer_return, evaluator|
      shipped_order = create(:shipped_order, line_items_count: evaluator.line_items_count)

      shipped_order.inventory_units.take(evaluator.return_items_count).each do |inventory_unit|
        customer_return.return_items << build(:return_item, inventory_unit: inventory_unit)
      end
    end

    factory :customer_return_with_accepted_items do
      after(:create) do |customer_return|
        customer_return.return_items.each(&:accept!)
      end
    end
  end

  # for the case when you want to supply existing return items instead of generating some
  factory :customer_return_without_return_items, class: Spree::CustomerReturn do
    association(:stock_location, factory: :stock_location)
  end

end

Version data entries

87 entries across 87 versions & 2 rubygems

Version Path
spree_core-3.1.14 lib/spree/testing_support/factories/customer_return_factory.rb
spree_core-3.1.13 lib/spree/testing_support/factories/customer_return_factory.rb
spree_core-3.3.4 lib/spree/testing_support/factories/customer_return_factory.rb
spree_core-3.2.7 lib/spree/testing_support/factories/customer_return_factory.rb
spree_core-3.1.12 lib/spree/testing_support/factories/customer_return_factory.rb
solidus_core-1.1.4 lib/spree/testing_support/factories/customer_return_factory.rb
solidus_core-1.0.7 lib/spree/testing_support/factories/customer_return_factory.rb
spree_core-3.3.3 lib/spree/testing_support/factories/customer_return_factory.rb
spree_core-3.2.6 lib/spree/testing_support/factories/customer_return_factory.rb
spree_core-3.1.11 lib/spree/testing_support/factories/customer_return_factory.rb
spree_core-3.1.10 lib/spree/testing_support/factories/customer_return_factory.rb
spree_core-3.3.2 lib/spree/testing_support/factories/customer_return_factory.rb
spree_core-3.2.5 lib/spree/testing_support/factories/customer_return_factory.rb
spree_core-3.1.9 lib/spree/testing_support/factories/customer_return_factory.rb
spree_core-3.3.1 lib/spree/testing_support/factories/customer_return_factory.rb
spree_core-3.2.4 lib/spree/testing_support/factories/customer_return_factory.rb
spree_core-3.1.8 lib/spree/testing_support/factories/customer_return_factory.rb
spree_core-3.3.0 lib/spree/testing_support/factories/customer_return_factory.rb
spree_core-3.3.0.rc4 lib/spree/testing_support/factories/customer_return_factory.rb
spree_core-3.3.0.rc3 lib/spree/testing_support/factories/customer_return_factory.rb