Welcome to mirror list, hosted at ThFree Co, Russian Federation.

relation_tree_restorer_spec.rb « group « import_export « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5e84284a060834c19d074b2e2de8fe62bd58257f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# frozen_string_literal: true

# This spec is a lightweight version of:
#   * project/tree_restorer_spec.rb
#
# In depth testing is being done in the above specs.
# This spec tests that restore project works
# but does not have 100% relation coverage.

require 'spec_helper'

RSpec.describe Gitlab::ImportExport::Group::RelationTreeRestorer do
  let(:group) { create(:group).tap { |g| g.add_owner(user) } }
  let(:importable) { create(:group, parent: group) }

  include_context 'relation tree restorer shared context' do
    let(:importable_name) { nil }
  end

  let(:path) { 'spec/fixtures/lib/gitlab/import_export/group_exports/no_children/group.json' }
  let(:relation_reader) do
    Gitlab::ImportExport::Json::LegacyReader::File.new(
      path,
      relation_names: reader.group_relation_names)
  end

  let(:reader) do
    Gitlab::ImportExport::Reader.new(
      shared: shared,
      config: Gitlab::ImportExport::Config.new(config: Gitlab::ImportExport.legacy_group_config_file).to_h
    )
  end

  let(:relation_tree_restorer) do
    described_class.new(
      user: user,
      shared: shared,
      relation_reader: relation_reader,
      object_builder: Gitlab::ImportExport::Group::ObjectBuilder,
      members_mapper: members_mapper,
      relation_factory: Gitlab::ImportExport::Group::RelationFactory,
      reader: reader,
      importable: importable,
      importable_path: nil,
      importable_attributes: attributes
    )
  end

  subject { relation_tree_restorer.restore }

  it 'restores group tree' do
    expect(subject).to eq(true)
  end

  it 'logs top-level relation creation' do
    expect(shared.logger)
      .to receive(:info)
      .with(hash_including(message: '[Project/Group Import] Created new object relation'))
      .at_least(:once)

    subject
  end
end