debian-mirror-gitlab/spec/factories/work_items/parent_links.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
650 B
Ruby
Raw Normal View History

2022-07-23 23:45:48 +05:30
# 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