Sha256: f9e6c726499de5e01027c6d37ea8b2e9ed5286ed5a905f1a30087200b1d18739
Contents?: true
Size: 1.26 KB
Versions: 33
Compression:
Stored size: 1.26 KB
Contents
FactoryBot.define do # 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) before(:create) do |customer_return, _evaluator| if customer_return.store.nil? default_store = Spree::Store.default.persisted? ? Spree::Store.default : nil store = default_store || create(:store) customer_return.store = store end end factory :customer_return, class: Spree::CustomerReturn do 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, store: customer_return.store) 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 end end
Version data entries
33 entries across 33 versions & 1 rubygems