Welcome to mirror list, hosted at ThFree Co, Russian Federation.

parent_links.rb « work_items « factories « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 886aa449a575443cacd18d976f5254a5951dd46a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 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