Commit 14c536f7 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'georgekoltsov/add-more-relations-to-group-export' into 'master'

Add more relations to Group Export

See merge request gitlab-org/gitlab!21504
parents 2c30616f f0beda36
...@@ -6,10 +6,16 @@ describe Gitlab::ImportExport::GroupTreeSaver do ...@@ -6,10 +6,16 @@ describe Gitlab::ImportExport::GroupTreeSaver do
describe 'saves the group tree into a json object' do describe 'saves the group tree into a json object' do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }
let_it_be(:epic) { create(:epic, group: group) } let_it_be(:label) { create(:group_label) }
let_it_be(:parent_epic) { create(:epic, group: group) }
let_it_be(:epic) { create(:epic, group: group, parent: parent_epic) }
let_it_be(:board) { create(:board, group: group, assignee: user, labels: [label]) }
let_it_be(:note) { create(:note, noteable: epic) }
let(:shared) { Gitlab::ImportExport::Shared.new(group) } let(:shared) { Gitlab::ImportExport::Shared.new(group) }
let(:export_path) { "#{Dir.tmpdir}/group_tree_saver_spec_ee" } let(:export_path) { "#{Dir.tmpdir}/group_tree_saver_spec_ee" }
let(:group_tree_saver) { described_class.new(group: group, current_user: user, shared: shared) } let(:group_tree_saver) { described_class.new(group: group, current_user: user, shared: shared) }
let(:saved_group_json) do let(:saved_group_json) do
group_tree_saver.save group_tree_saver.save
group_json(group_tree_saver.full_path) group_json(group_tree_saver.full_path)
...@@ -27,8 +33,42 @@ describe Gitlab::ImportExport::GroupTreeSaver do ...@@ -27,8 +33,42 @@ describe Gitlab::ImportExport::GroupTreeSaver do
expect(group_tree_saver.save).to be true expect(group_tree_saver.save).to be true
end end
it 'saves epics' do context 'epics relation' do
expect(saved_group_json['epics'].size).to eq(1) it 'saves top level epics' do
expect(saved_group_json['epics'].size).to eq(2)
end
it 'saves parent of epic' do
parent = saved_group_json['epics'].first['parent']
expect(parent).not_to be_empty
expect(parent['id']).to eq(parent_epic.id)
end
it 'saves epic notes' do
notes = saved_group_json['epics'].first['notes']
expect(notes).not_to be_empty
expect(notes.first['note']).to eq(note.note)
expect(notes.first['noteable_id']).to eq(epic.id)
end
end
context 'boards relation' do
it 'saves top level boards' do
expect(saved_group_json['boards'].size).to eq(1)
end
it 'saves board assignee' do
expect(saved_group_json['boards'].first['board_assignee']['assignee_id']).to eq(user.id)
end
it 'saves board labels' do
labels = saved_group_json['boards'].first['labels']
expect(labels).not_to be_empty
expect(labels.first['title']).to eq(label.title)
end
end end
end end
......
...@@ -14,9 +14,16 @@ tree: ...@@ -14,9 +14,16 @@ tree:
- :user - :user
included_attributes: included_attributes:
user:
- :id
- :email
- :username
author:
- :name
excluded_attributes: excluded_attributes:
group: group:
- :id
- :runners_token - :runners_token
- :runners_token_encrypted - :runners_token_encrypted
...@@ -25,6 +32,8 @@ methods: ...@@ -25,6 +32,8 @@ methods:
- :type - :type
badges: badges:
- :type - :type
notes:
- :type
preloads: preloads:
...@@ -33,4 +42,11 @@ preloads: ...@@ -33,4 +42,11 @@ preloads:
ee: ee:
tree: tree:
group: group:
- :epics - epics:
- :parent
- notes:
- :author
- boards:
- :board_assignee
- labels:
- :priorities
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