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