Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
64bf46af
Commit
64bf46af
authored
Mar 11, 2019
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add labels to seeded issues and merge requests
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
f859b0e1
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
60 additions
and
106 deletions
+60
-106
db/fixtures/development/02_settings.rb
db/fixtures/development/02_settings.rb
+0
-0
db/fixtures/development/03_project.rb
db/fixtures/development/03_project.rb
+1
-1
db/fixtures/development/04_labels.rb
db/fixtures/development/04_labels.rb
+49
-0
db/fixtures/development/09_issues.rb
db/fixtures/development/09_issues.rb
+5
-1
db/fixtures/development/10_merge_requests.rb
db/fixtures/development/10_merge_requests.rb
+5
-1
db/fixtures/development/22_labeled_issues_seed.rb
db/fixtures/development/22_labeled_issues_seed.rb
+0
-103
No files found.
db/fixtures/development/0
3
_settings.rb
→
db/fixtures/development/0
2
_settings.rb
View file @
64bf46af
File moved
db/fixtures/development/0
4
_project.rb
→
db/fixtures/development/0
3
_project.rb
View file @
64bf46af
...
...
@@ -60,7 +60,7 @@ Sidekiq::Testing.inline! do
path:
group_path
)
group
.
description
=
FFaker
::
Lorem
.
sentence
group
.
save
group
.
save
!
group
.
add_owner
(
User
.
first
)
end
...
...
db/fixtures/development/04_labels.rb
0 → 100644
View file @
64bf46af
# frozen_string_literal: true
require
'digest/md5'
class
Gitlab::Seeder::GroupLabels
def
initialize
(
group
,
label_per_group:
10
)
@group
=
group
@label_per_group
=
label_per_group
end
def
seed!
@label_per_group
.
times
do
label_title
=
FFaker
::
Product
.
brand
Labels
::
CreateService
.
new
(
title:
label_title
,
color:
"#
#{
Digest
::
MD5
.
hexdigest
(
label_title
)[
0
..
5
]
}
"
)
.
execute
(
group:
@group
)
print
'.'
end
end
end
class
Gitlab::Seeder::ProjectLabels
def
initialize
(
project
,
label_per_project:
5
)
@project
=
project
@label_per_project
=
label_per_project
end
def
seed!
@label_per_project
.
times
do
label_title
=
FFaker
::
Vehicle
.
model
Labels
::
CreateService
.
new
(
title:
label_title
,
color:
"#
#{
Digest
::
MD5
.
hexdigest
(
label_title
)[
0
..
5
]
}
"
)
.
execute
(
project:
@project
)
print
'.'
end
end
end
Gitlab
::
Seeder
.
quiet
do
puts
"
\n
Generating group labels"
Group
.
all
.
find_each
do
|
group
|
Gitlab
::
Seeder
::
GroupLabels
.
new
(
group
).
seed!
end
puts
"
\n
Generating project labels"
Project
.
all
.
find_each
do
|
project
|
Gitlab
::
Seeder
::
ProjectLabels
.
new
(
project
).
seed!
end
end
db/fixtures/development/09_issues.rb
View file @
64bf46af
...
...
@@ -3,13 +3,17 @@ require './spec/support/sidekiq'
Gitlab
::
Seeder
.
quiet
do
Project
.
all
.
each
do
|
project
|
10
.
times
do
label_ids
=
project
.
labels
.
pluck
(
:id
).
sample
(
3
)
label_ids
+=
project
.
group
.
labels
.
sample
(
3
)
if
project
.
group
issue_params
=
{
title:
FFaker
::
Lorem
.
sentence
(
6
),
description:
FFaker
::
Lorem
.
sentence
,
state:
[
'opened'
,
'closed'
].
sample
,
milestone:
project
.
milestones
.
sample
,
assignees:
[
project
.
team
.
users
.
sample
],
created_at:
rand
(
12
).
months
.
ago
created_at:
rand
(
12
).
months
.
ago
,
label_ids:
label_ids
}
Issues
::
CreateService
.
new
(
project
,
project
.
team
.
users
.
sample
,
issue_params
).
execute
...
...
db/fixtures/development/10_merge_requests.rb
View file @
64bf46af
...
...
@@ -12,13 +12,17 @@ Gitlab::Seeder.quiet do
source_branch
=
branches
.
pop
target_branch
=
branches
.
pop
label_ids
=
project
.
labels
.
pluck
(
:id
).
sample
(
3
)
label_ids
+=
project
.
group
.
labels
.
sample
(
3
)
if
project
.
group
params
=
{
source_branch:
source_branch
,
target_branch:
target_branch
,
title:
FFaker
::
Lorem
.
sentence
(
6
),
description:
FFaker
::
Lorem
.
sentences
(
3
).
join
(
" "
),
milestone:
project
.
milestones
.
sample
,
assignee:
project
.
team
.
users
.
sample
assignee:
project
.
team
.
users
.
sample
,
label_ids:
label_ids
}
# Only create MRs with users that are allowed to create MRs
...
...
db/fixtures/development/22_labeled_issues_seed.rb
deleted
100644 → 0
View file @
f859b0e1
# Creates a project with labeled issues for an user.
# Run this single seed file using: rake db:seed_fu FILTER=labeled USER_ID=74.
# If an USER_ID is not provided it will use the last created user.
require
'./spec/support/sidekiq'
class
Gitlab::Seeder::LabeledIssues
include
::
Gitlab
::
Utils
def
initialize
(
user
)
@user
=
user
end
def
seed!
Sidekiq
::
Testing
.
inline!
do
group
=
create_group
create_projects
(
group
)
create_labels
(
group
)
create_issues
(
group
)
end
print
'.'
end
private
def
create_group
group_name
=
"group_of_
#{
@user
.
username
}
_
#{
SecureRandom
.
hex
(
4
)
}
"
group_params
=
{
name:
group_name
,
path:
group_name
,
description:
FFaker
::
Lorem
.
sentence
}
Groups
::
CreateService
.
new
(
@user
,
group_params
).
execute
end
def
create_projects
(
group
)
5
.
times
do
project_name
=
"project_
#{
SecureRandom
.
hex
(
6
)
}
"
params
=
{
namespace_id:
group
.
id
,
name:
project_name
,
description:
FFaker
::
Lorem
.
sentence
,
visibility_level:
Gitlab
::
VisibilityLevel
.
values
.
sample
}
Projects
::
CreateService
.
new
(
@user
,
params
).
execute
end
end
def
create_labels
(
group
)
group
.
projects
.
each
do
|
project
|
5
.
times
do
label_title
=
FFaker
::
Vehicle
.
model
Labels
::
CreateService
.
new
(
title:
label_title
,
color:
"#69D100"
).
execute
(
project:
project
)
end
end
10
.
times
do
label_title
=
FFaker
::
Product
.
brand
Labels
::
CreateService
.
new
(
title:
label_title
).
execute
(
group:
group
)
end
end
def
create_issues
(
group
)
# Get only group labels
group_labels
=
LabelsFinder
.
new
(
@user
,
group_id:
group
.
id
).
execute
.
where
.
not
(
group_id:
nil
)
group
.
projects
.
each
do
|
project
|
label_ids
=
project
.
labels
.
pluck
(
:id
).
sample
(
5
)
label_ids
.
push
(
*
group
.
labels
.
sample
(
4
))
20
.
times
do
issue_params
=
{
title:
FFaker
::
Lorem
.
sentence
(
6
),
description:
FFaker
::
Lorem
.
sentence
,
state:
'opened'
,
label_ids:
label_ids
}
Issues
::
CreateService
.
new
(
project
,
@user
,
issue_params
).
execute
if
project
.
project_feature
.
present?
end
end
end
end
Gitlab
::
Seeder
.
quiet
do
user_id
=
ENV
[
'USER_ID'
]
user
=
if
user_id
.
present?
User
.
find
(
user_id
)
else
User
.
last
end
Gitlab
::
Seeder
::
LabeledIssues
.
new
(
user
).
seed!
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment