2020-01-01 13:55:28 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-06-22 15:30:34 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe Gitlab::ImportExport::Reader do
|
2018-03-27 19:54:05 +05:30
|
|
|
let(:shared) { Gitlab::ImportExport::Shared.new(nil) }
|
2016-09-29 09:46:39 +05:30
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
describe '#project_tree' do
|
|
|
|
subject { described_class.new(shared: shared).project_tree }
|
2016-09-29 09:46:39 +05:30
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
it 'delegates to AttributesFinder#find_root' do
|
2020-01-01 13:55:28 +05:30
|
|
|
expect_next_instance_of(Gitlab::ImportExport::AttributesFinder) do |instance|
|
|
|
|
expect(instance).to receive(:find_root).with(:project)
|
|
|
|
end
|
2016-06-22 15:30:34 +05:30
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
subject
|
2016-06-22 15:30:34 +05:30
|
|
|
end
|
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
context 'when exception raised' do
|
|
|
|
before do
|
2020-01-01 13:55:28 +05:30
|
|
|
expect_next_instance_of(Gitlab::ImportExport::AttributesFinder) do |instance|
|
|
|
|
expect(instance).to receive(:find_root).with(:project).and_raise(StandardError)
|
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
end
|
2016-06-22 15:30:34 +05:30
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
it { is_expected.to be false }
|
2016-06-22 15:30:34 +05:30
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
it 'logs the error' do
|
|
|
|
expect(shared).to receive(:error).with(instance_of(StandardError))
|
2016-06-22 15:30:34 +05:30
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
subject
|
|
|
|
end
|
2016-06-22 15:30:34 +05:30
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
end
|
2016-06-22 15:30:34 +05:30
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
describe '#group_members_tree' do
|
|
|
|
subject { described_class.new(shared: shared).group_members_tree }
|
2016-06-22 15:30:34 +05:30
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
it 'delegates to AttributesFinder#find_root' do
|
2020-01-01 13:55:28 +05:30
|
|
|
expect_next_instance_of(Gitlab::ImportExport::AttributesFinder) do |instance|
|
|
|
|
expect(instance).to receive(:find_root).with(:group_members)
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
subject
|
2016-06-22 15:30:34 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|