Skip to content

Issues

Create an issue

By default, an issue will automatically create an associated project and group. In this example, we will reference an existing project.

my_group = create(:group, name: 'My Group', path: 'my-group-path')
my_project = create(:project, :public, name: 'My Project', namespace: my_group, creator: @owner)
# create the issue
my_issue = create(:issue, title: 'My Issue', project: my_project, weight: 2)

Relate an issue to another issue

Using the issue_link factory, we can link two issues.

create(:project, name: 'My Project', namespace: @group, creator: @owner) do |project|
issue_1 = create(:issue, project: project, title: 'issue 1')
issue_2 = create(:issue, project: project, title: 'issue 2')
create(:issue_link, source: issue_1, target: issue_2)
end

Add an issue to a milestone

issue_1 =
create(
:issue,
project: project,
title: "Issue One",
assignees: [user_one],
author: user_two,
due_date: 85.days.ago,
weight: 3,
labels: [
labels[:priority_high],
labels[:theme_delight_users],
labels[:type_feature]
],
confidential: false,
state: "closed",
closed_at: 101.days.ago,
epic: @level2_epics[:epic_693728],
milestone: milestones[:SP_6],
created_at: 110.days.ago,
description: <<~MARKDOWN
Issue One Description
MARKDOWN
)
create(
:resource_milestone_event,
issue: issue_1,
milestone: milestones[:SP_6],
created_at: 110.days.ago,
action: "add"
)
create(
:resource_state_event,
issue: issue_1,
created_at: 101.days.ago,
state: "closed"
)

Add an issue to a merge request

issue_1 =
create(
:issue,
project: project,
title: "Issue One",
assignees: [user_one],
author: user_two,
due_date: 85.days.ago,
weight: 3,
labels: [
labels[:priority_high],
labels[:theme_delight_users],
labels[:type_feature]
],
confidential: false,
state: "closed",
closed_at: 101.days.ago,
epic: @level2_epics[:epic_693728],
milestone: milestones[:SP_6],
created_at: 110.days.ago,
description: <<~MARKDOWN
Issue one description
MARKDOWN
)
mr_1 =
create(
:merge_request,
:merged,
source_project: project,
title: "Merge Request One",
assignees: [user_one],
author: user_two,
source_branch: "branch-1675362373",
target_branch: "main",
draft: false,
created_at: 103.days.ago,
milestone: milestones[:SP_6],
description: <<~MARKDOWN
Merge Request description
MARKDOWN
)