add specs
This commit is contained in:
parent
e902aa0d5a
commit
45db0575b1
46 changed files with 714 additions and 238 deletions
21
spec/factories/multi_order.rb
Normal file
21
spec/factories/multi_order.rb
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
require 'factory_bot'
|
||||
|
||||
FactoryBot.define do
|
||||
factory :multi_order do
|
||||
transient do
|
||||
orders { [create(:order, state: 'closed')] }
|
||||
end
|
||||
|
||||
after(:build) do |multi_order, evaluator|
|
||||
# Assign orders before validation so custom validations can see them
|
||||
multi_order.orders = evaluator.orders
|
||||
end
|
||||
|
||||
after(:create) do |multi_order, _evaluator|
|
||||
# Persist the relationship by updating the orders (if needed)
|
||||
multi_order.orders.each do |order|
|
||||
order.update!(multi_order: multi_order)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue