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
Boxiang Sun
gitlab-ce
Commits
49ec98d1
Commit
49ec98d1
authored
Oct 17, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Recreates the label priorities when moving project to another group
parent
301264be
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletion
+12
-1
app/services/labels/transfer_service.rb
app/services/labels/transfer_service.rb
+2
-1
spec/services/labels/transfer_service_spec.rb
spec/services/labels/transfer_service_spec.rb
+10
-0
No files found.
app/services/labels/transfer_service.rb
View file @
49ec98d1
...
@@ -14,7 +14,7 @@ module Labels
...
@@ -14,7 +14,7 @@ module Labels
return
unless
group
.
present?
return
unless
group
.
present?
Label
.
transaction
do
Label
.
transaction
do
labels_to_transfer
=
Label
.
where
(
id:
label_links
.
select
(
:label_id
)
.
uniq
)
labels_to_transfer
=
Label
.
where
(
id:
label_links
.
select
(
:label_id
))
labels_to_transfer
.
find_each
do
|
label
|
labels_to_transfer
.
find_each
do
|
label
|
new_label_id
=
find_or_create_label!
(
label
)
new_label_id
=
find_or_create_label!
(
label
)
...
@@ -22,6 +22,7 @@ module Labels
...
@@ -22,6 +22,7 @@ module Labels
next
if
new_label_id
==
label
.
id
next
if
new_label_id
==
label
.
id
LabelLink
.
where
(
label_id:
label
.
id
).
update_all
(
label_id:
new_label_id
)
LabelLink
.
where
(
label_id:
label
.
id
).
update_all
(
label_id:
new_label_id
)
LabelPriority
.
where
(
project_id:
project
.
id
,
label_id:
label
.
id
).
update_all
(
label_id:
new_label_id
)
end
end
end
end
end
end
...
...
spec/services/labels/transfer_service_spec.rb
View file @
49ec98d1
...
@@ -26,6 +26,16 @@ describe Labels::TransferService, services: true do
...
@@ -26,6 +26,16 @@ describe Labels::TransferService, services: true do
expect
{
service
.
execute
}.
to
change
(
project
.
labels
,
:count
).
by
(
2
)
expect
{
service
.
execute
}.
to
change
(
project
.
labels
,
:count
).
by
(
2
)
end
end
it
'recreates label priorities related to the missing group labels'
do
create
(
:label_priority
,
project:
project
,
label:
group_label_1
,
priority:
1
)
service
.
execute
new_project_label
=
project
.
labels
.
find_by
(
title:
group_label_1
.
title
)
expect
(
new_project_label
.
id
).
not_to
eq
group_label_1
.
id
expect
(
new_project_label
.
priorities
).
not_to
be_empty
end
it
'does not recreate missing group labels that are not applied to issues or merge requests'
do
it
'does not recreate missing group labels that are not applied to issues or merge requests'
do
service
.
execute
service
.
execute
...
...
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