diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /spec/factories/work_items/parent_links.rb | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'spec/factories/work_items/parent_links.rb')
-rw-r--r-- | spec/factories/work_items/parent_links.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/factories/work_items/parent_links.rb b/spec/factories/work_items/parent_links.rb new file mode 100644 index 00000000000..886aa449a57 --- /dev/null +++ b/spec/factories/work_items/parent_links.rb @@ -0,0 +1,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 |