Commit 89040ac8 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'georgekoltsov/import-export-epic-labels' into 'master'

Preserve epic labels association during Group Import/Export

See merge request gitlab-org/gitlab!62074
parents 59ae7774 f105ac61
---
title: Preserve epic labels association during Group Import/Export
merge_request: 62074
author:
type: fixed
...@@ -87,7 +87,11 @@ ...@@ -87,7 +87,11 @@
"updated_at": "2019-11-20T17:27:41.118Z", "updated_at": "2019-11-20T17:27:41.118Z",
"name": "first board", "name": "first board",
"milestone_id": -2, "milestone_id": -2,
"milestone": {"id": -2, "name": "#upcoming", "title": "Upcoming"}, "milestone": {
"id": -2,
"name": "#upcoming",
"title": "Upcoming"
},
"group_id": 4351, "group_id": 4351,
"weight": null, "weight": null,
"labels": [], "labels": [],
...@@ -289,6 +293,24 @@ ...@@ -289,6 +293,24 @@
"created_at": "2019-11-05T15:37:21.287Z", "created_at": "2019-11-05T15:37:21.287Z",
"updated_at": "2019-11-05T15:37:21.287Z" "updated_at": "2019-11-05T15:37:21.287Z"
} }
],
"label_links": [
{
"id": 1,
"label_id": 2,
"target_id": 3,
"target_type": "Epic",
"created_at": "2021-04-14 14:42:21.717503",
"updated_at": "2021-04-14 14:42:21.717503",
"label": {
"title": "title",
"description": "description",
"color": "#cd2c5c",
"created_at": "2021-04-14 14:42:21.717503",
"updated_at": "2021-04-14 14:42:21.717503",
"type": "GroupLabel"
}
}
] ]
}, },
{ {
...@@ -321,7 +343,25 @@ ...@@ -321,7 +343,25 @@
"state": "closed", "state": "closed",
"start_date_sourcing_epic_id": null, "start_date_sourcing_epic_id": null,
"due_date_sourcing_epic_id": null, "due_date_sourcing_epic_id": null,
"notes": [] "notes": [],
"label_links": [
{
"id": 1,
"label_id": 2,
"target_id": 3,
"target_type": "Epic",
"created_at": "2021-04-14 14:42:21.717503",
"updated_at": "2021-04-14 14:42:21.717503",
"label": {
"title": "title",
"description": "description",
"color": "#cd2c5c",
"created_at": "2021-04-14 14:42:21.717503",
"updated_at": "2021-04-14 14:42:21.717503",
"type": "GroupLabel"
}
}
]
} }
] ]
} }
{"id":13622,"milestone_id":null,"group_id":4351,"author_id":1,"assignee_id":null,"iid":1,"updated_by_id":null,"last_edited_by_id":null,"lock_version":0,"start_date":null,"end_date":null,"last_edited_at":null,"created_at":"2019-11-20T17:02:09.754Z","updated_at":"2019-11-20T18:38:40.054Z","title":"Provident neque consequatur numquam ad laboriosam voluptatem magnam.","description":"Fugit nisi est ut numquam quia rerum vitae qui. Et in est aliquid voluptas et ut vitae. In distinctio voluptates ut deleniti iste.\n\nReiciendis eum sunt vero blanditiis at quia. Voluptate eum facilis illum ea distinctio maiores. Doloribus aut nemo ea distinctio.\n\nNihil cum distinctio voluptates quam. Laboriosam distinctio ea accusantium soluta perspiciatis nesciunt impedit. Id qui natus quis minima voluptatum velit ut reprehenderit. Molestiae quia est harum sapiente rem error architecto id. Et minus ipsa et ut ut.","start_date_sourcing_milestone_id":null,"due_date_sourcing_milestone_id":null,"start_date_fixed":null,"due_date_fixed":null,"start_date_is_fixed":null,"due_date_is_fixed":null,"closed_by_id":null,"closed_at":null,"parent_id":null,"relative_position":null,"state":"opened","start_date_sourcing_epic_id":null,"due_date_sourcing_epic_id":null,"notes":[{"id":44164,"note":"added epic &2 as child epic","noteable_type":"Epic","author_id":1,"created_at":"2019-11-20T18:38:26.689Z","updated_at":"2019-11-20T18:38:26.724Z","project_id":null,"attachment":{"url":null},"line_code":null,"commit_id":null,"noteable_id":13622,"system":true,"st_diff":null,"updated_by_id":null,"position":null,"original_position":null,"resolved_at":null,"resolved_by_id":null,"discussion_id":"133f0c3001860fa8d2031e398a65db74477378c4","change_position":null,"resolved_by_push":null,"review_id":null,"type":null,"author":{"name":"Administrator"},"award_emoji":[{"id":12,"name":"drum","user_id":1,"awardable_type":"Note","awardable_id":44170,"created_at":"2019-11-05T15:32:21.287Z","updated_at":"2019-11-05T15:32:21.287Z"}]}],"award_emoji":[{"id":12,"name":"thumbsup","user_id":1,"awardable_type":"Epic","awardable_id":13622,"created_at":"2019-11-05T15:37:21.287Z","updated_at":"2019-11-05T15:37:21.287Z"}]} {"id":13622,"milestone_id":null,"group_id":4351,"author_id":1,"assignee_id":null,"iid":1,"updated_by_id":null,"last_edited_by_id":null,"lock_version":0,"start_date":null,"end_date":null,"last_edited_at":null,"created_at":"2019-11-20T17:02:09.754Z","updated_at":"2019-11-20T18:38:40.054Z","title":"Provident neque consequatur numquam ad laboriosam voluptatem magnam.","description":"Fugit nisi est ut numquam quia rerum vitae qui. Et in est aliquid voluptas et ut vitae. In distinctio voluptates ut deleniti iste.\n\nReiciendis eum sunt vero blanditiis at quia. Voluptate eum facilis illum ea distinctio maiores. Doloribus aut nemo ea distinctio.\n\nNihil cum distinctio voluptates quam. Laboriosam distinctio ea accusantium soluta perspiciatis nesciunt impedit. Id qui natus quis minima voluptatum velit ut reprehenderit. Molestiae quia est harum sapiente rem error architecto id. Et minus ipsa et ut ut.","start_date_sourcing_milestone_id":null,"due_date_sourcing_milestone_id":null,"start_date_fixed":null,"due_date_fixed":null,"start_date_is_fixed":null,"due_date_is_fixed":null,"closed_by_id":null,"closed_at":null,"parent_id":null,"relative_position":null,"state":"opened","start_date_sourcing_epic_id":null,"due_date_sourcing_epic_id":null,"notes":[{"id":44164,"note":"added epic &2 as child epic","noteable_type":"Epic","author_id":1,"created_at":"2019-11-20T18:38:26.689Z","updated_at":"2019-11-20T18:38:26.724Z","project_id":null,"attachment":{"url":null},"line_code":null,"commit_id":null,"noteable_id":13622,"system":true,"st_diff":null,"updated_by_id":null,"position":null,"original_position":null,"resolved_at":null,"resolved_by_id":null,"discussion_id":"133f0c3001860fa8d2031e398a65db74477378c4","change_position":null,"resolved_by_push":null,"review_id":null,"type":null,"author":{"name":"Administrator"},"award_emoji":[{"id":12,"name":"drum","user_id":1,"awardable_type":"Note","awardable_id":44170,"created_at":"2019-11-05T15:32:21.287Z","updated_at":"2019-11-05T15:32:21.287Z"}]}],"award_emoji":[{"id":12,"name":"thumbsup","user_id":1,"awardable_type":"Epic","awardable_id":13622,"created_at":"2019-11-05T15:37:21.287Z","updated_at":"2019-11-05T15:37:21.287Z"}],"label_links":[{"id":1,"label_id":2,"target_id":3,"target_type":"Epic","created_at":"2021-04-14 14:42:21.717503","updated_at":"2021-04-14 14:42:21.717503","label":{"title":"title","description":"description","color":"#cd2c5c","created_at":"2021-04-14 14:42:21.717503","updated_at":"2021-04-14 14:42:21.717503","type":"GroupLabel"}}]}
{"id":13623,"milestone_id":null,"group_id":4351,"author_id":1,"assignee_id":null,"iid":2,"updated_by_id":null,"last_edited_by_id":null,"lock_version":0,"start_date":null,"end_date":null,"last_edited_at":null,"created_at":"2019-12-20T17:02:09.754Z","updated_at":"2019-12-20T18:38:40.054Z","title":"Provident neque consequatur numquam ad voluptatem magnam.","description":"Fugit nisi","start_date_sourcing_milestone_id":null,"due_date_sourcing_milestone_id":null,"start_date_fixed":null,"due_date_fixed":null,"start_date_is_fixed":null,"due_date_is_fixed":null,"closed_by_id":null,"closed_at":null,"parent_id":null,"relative_position":null,"state":"closed","start_date_sourcing_epic_id":null,"due_date_sourcing_epic_id":null,"notes":[]} {"id":13623,"milestone_id":null,"group_id":4351,"author_id":1,"assignee_id":null,"iid":2,"updated_by_id":null,"last_edited_by_id":null,"lock_version":0,"start_date":null,"end_date":null,"last_edited_at":null,"created_at":"2019-12-20T17:02:09.754Z","updated_at":"2019-12-20T18:38:40.054Z","title":"Provident neque consequatur numquam ad voluptatem magnam.","description":"Fugit nisi","start_date_sourcing_milestone_id":null,"due_date_sourcing_milestone_id":null,"start_date_fixed":null,"due_date_fixed":null,"start_date_is_fixed":null,"due_date_is_fixed":null,"closed_by_id":null,"closed_at":null,"parent_id":null,"relative_position":null,"state":"closed","start_date_sourcing_epic_id":null,"due_date_sourcing_epic_id":null,"notes":[],"label_links":[{"id":1,"label_id":2,"target_id":3,"target_type":"Epic","created_at":"2021-04-14 14:42:21.717503","updated_at":"2021-04-14 14:42:21.717503","label":{"title":"title","description":"description","color":"#cd2c5c","created_at":"2021-04-14 14:42:21.717503","updated_at":"2021-04-14 14:42:21.717503","type":"GroupLabel"}}]}
...@@ -44,6 +44,17 @@ RSpec.describe Gitlab::ImportExport::Group::LegacyTreeRestorer do ...@@ -44,6 +44,17 @@ RSpec.describe Gitlab::ImportExport::Group::LegacyTreeRestorer do
end end
end end
context 'epic labels' do
it 'has epic labels' do
label = group.epics.first.labels.first
expect(group.epics.first.labels.count).to eq(1)
expect(label.title).to eq('title')
expect(label.description).to eq('description')
expect(label.color).to eq('#cd2c5c')
end
end
context 'board lists' do context 'board lists' do
it 'has milestone & assignee lists' do it 'has milestone & assignee lists' do
lists = group.boards.find_by(name: 'first board').lists lists = group.boards.find_by(name: 'first board').lists
......
...@@ -10,6 +10,7 @@ RSpec.describe Gitlab::ImportExport::Group::LegacyTreeSaver do ...@@ -10,6 +10,7 @@ RSpec.describe Gitlab::ImportExport::Group::LegacyTreeSaver do
let_it_be(:parent_epic) { create(:epic, group: group) } let_it_be(:parent_epic) { create(:epic, group: group) }
let_it_be(:epic) { create(:epic, group: group, parent: parent_epic) } let_it_be(:epic) { create(:epic, group: group, parent: parent_epic) }
let_it_be(:epic_event) { create(:event, :created, target: epic, group: group, author: user) } let_it_be(:epic_event) { create(:event, :created, target: epic, group: group, author: user) }
let_it_be(:epic_label_link) { create(:label_link, label: label, target: epic) }
let_it_be(:epic_push_event) { create(:event, :pushed, target: epic, group: group, author: user) } let_it_be(:epic_push_event) { create(:event, :pushed, target: epic, group: group, author: user) }
let_it_be(:milestone) { create(:milestone, group: group) } let_it_be(:milestone) { create(:milestone, group: group) }
let_it_be(:board) { create(:board, group: group, assignee: user, labels: [label]) } let_it_be(:board) { create(:board, group: group, assignee: user, labels: [label]) }
...@@ -99,6 +100,15 @@ RSpec.describe Gitlab::ImportExport::Group::LegacyTreeSaver do ...@@ -99,6 +100,15 @@ RSpec.describe Gitlab::ImportExport::Group::LegacyTreeSaver do
award_emoji = epic_json['notes'].first['award_emoji'].first award_emoji = epic_json['notes'].first['award_emoji'].first
expect(award_emoji['name']).to eq(epic_note_emoji.name) expect(award_emoji['name']).to eq(epic_note_emoji.name)
end end
it 'saves epic labels' do
expect_successful_save(group_tree_saver)
epic_label = epic_json['label_links'].first['label']
expect(epic_label['title']).to eq(label.title)
expect(epic_label['description']).to eq(label.description)
expect(epic_label['color']).to eq(label.color)
end
end end
context 'boards relation' do context 'boards relation' do
......
...@@ -44,6 +44,17 @@ RSpec.describe Gitlab::ImportExport::Group::TreeRestorer do ...@@ -44,6 +44,17 @@ RSpec.describe Gitlab::ImportExport::Group::TreeRestorer do
end end
end end
context 'epic labels' do
it 'has epic labels' do
label = group.epics.first.labels.first
expect(group.epics.first.labels.count).to eq(1)
expect(label.title).to eq('title')
expect(label.description).to eq('description')
expect(label.color).to eq('#cd2c5c')
end
end
context 'board lists' do context 'board lists' do
it 'has milestone & assignee lists' do it 'has milestone & assignee lists' do
lists = group.boards.find_by(name: 'first board').lists lists = group.boards.find_by(name: 'first board').lists
......
...@@ -10,6 +10,7 @@ RSpec.describe Gitlab::ImportExport::Group::TreeSaver do ...@@ -10,6 +10,7 @@ RSpec.describe Gitlab::ImportExport::Group::TreeSaver do
let_it_be(:parent_epic) { create(:epic, group: group) } let_it_be(:parent_epic) { create(:epic, group: group) }
let_it_be(:epic) { create(:epic, group: group, parent: parent_epic) } let_it_be(:epic) { create(:epic, group: group, parent: parent_epic) }
let_it_be(:epic_event) { create(:event, :created, target: epic, group: group, author: user) } let_it_be(:epic_event) { create(:event, :created, target: epic, group: group, author: user) }
let_it_be(:epic_label_link) { create(:label_link, label: label, target: epic) }
let_it_be(:epic_push_event) { create(:event, :pushed, target: epic, group: group, author: user) } let_it_be(:epic_push_event) { create(:event, :pushed, target: epic, group: group, author: user) }
let_it_be(:milestone) { create(:milestone, group: group) } let_it_be(:milestone) { create(:milestone, group: group) }
let_it_be(:board) { create(:board, group: group, assignee: user, labels: [label]) } let_it_be(:board) { create(:board, group: group, assignee: user, labels: [label]) }
...@@ -97,6 +98,15 @@ RSpec.describe Gitlab::ImportExport::Group::TreeSaver do ...@@ -97,6 +98,15 @@ RSpec.describe Gitlab::ImportExport::Group::TreeSaver do
award_emoji = epic_json['notes'].first['award_emoji'].first award_emoji = epic_json['notes'].first['award_emoji'].first
expect(award_emoji['name']).to eq(epic_note_emoji.name) expect(award_emoji['name']).to eq(epic_note_emoji.name)
end end
it 'saves epic labels' do
expect_successful_save(group_tree_saver)
epic_label = epic_json['label_links'].first['label']
expect(epic_label['title']).to eq(label.title)
expect(epic_label['description']).to eq(label.description)
expect(epic_label['color']).to eq(label.color)
end
end end
context 'boards relation' do context 'boards relation' do
......
...@@ -70,6 +70,8 @@ ee: ...@@ -70,6 +70,8 @@ ee:
- :award_emoji - :award_emoji
- events: - events:
- :push_event_payload - :push_event_payload
- label_links:
- :label
- notes: - notes:
- :author - :author
- :award_emoji - :award_emoji
......
...@@ -72,6 +72,8 @@ ee: ...@@ -72,6 +72,8 @@ ee:
- :award_emoji - :award_emoji
- events: - events:
- :push_event_payload - :push_event_payload
- label_links:
- :label
- notes: - notes:
- :author - :author
- :award_emoji - :award_emoji
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment