debian-mirror-gitlab/spec/factories/work_items/parent_links.rb
2022-07-23 20:15:48 +02:00

21 lines
650 B
Ruby

# frozen_string_literal: true
FactoryBot.define do
factory :parent_link, class: 'WorkItems::ParentLink' do
transient do
work_item { nil }
work_item_parent { nil }
end
after(:build) do |link, evaluator|
link.work_item = evaluator.work_item
link.work_item_parent = evaluator.work_item_parent
unless link.work_item && link.work_item_parent
project = link.work_item&.project || link.work_item_parent&.project || create(:project)
link.work_item ||= create(:work_item, :task, project: project)
link.work_item_parent ||= create(:work_item, project: project)
end
end
end
end