Commit b5b99864 authored by Rémy Coutable's avatar Rémy Coutable

Add expectation in Gitlab::ImportExport::GroupTreeSaver specs

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 56a7cabe
......@@ -17,7 +17,6 @@ describe Gitlab::ImportExport::GroupTreeSaver do
let(:group_tree_saver) { described_class.new(group: group, current_user: user, shared: shared) }
let(:saved_group_json) do
group_tree_saver.save
group_json(group_tree_saver.full_path)
end
......@@ -30,15 +29,18 @@ describe Gitlab::ImportExport::GroupTreeSaver do
end
it 'saves successfully' do
expect(group_tree_saver.save).to be true
expect_successful_save(group_tree_saver)
end
context 'epics relation' do
it 'saves top level epics' do
expect_successful_save(group_tree_saver)
expect(saved_group_json['epics'].size).to eq(2)
end
it 'saves parent of epic' do
expect_successful_save(group_tree_saver)
parent = saved_group_json['epics'].first['parent']
expect(parent).not_to be_empty
......@@ -46,6 +48,8 @@ describe Gitlab::ImportExport::GroupTreeSaver do
end
it 'saves epic notes' do
expect_successful_save(group_tree_saver)
notes = saved_group_json['epics'].first['notes']
expect(notes).not_to be_empty
......@@ -56,14 +60,18 @@ describe Gitlab::ImportExport::GroupTreeSaver do
context 'boards relation' do
it 'saves top level boards' do
expect_successful_save(group_tree_saver)
expect(saved_group_json['boards'].size).to eq(1)
end
it 'saves board assignee' do
expect_successful_save(group_tree_saver)
expect(saved_group_json['boards'].first['board_assignee']['assignee_id']).to eq(user.id)
end
it 'saves board labels' do
expect_successful_save(group_tree_saver)
labels = saved_group_json['boards'].first['labels']
expect(labels).not_to be_empty
......@@ -72,6 +80,11 @@ describe Gitlab::ImportExport::GroupTreeSaver do
end
end
def expect_successful_save(group_tree_saver)
expect(group_tree_saver.save).to be true
expect(group_tree_saver.shared.errors).to be_empty
end
def group_json(filename)
JSON.parse(IO.read(filename))
end
......
......@@ -3,7 +3,7 @@
module Gitlab
module ImportExport
class GroupTreeSaver
attr_reader :full_path
attr_reader :full_path, :shared
def initialize(group:, current_user:, shared:, params: {})
@params = params
......
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