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

repo_saver_spec.rb « import_export « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 73e0e0a08b9b835e35de9d9a35296c05d9effa2c (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::ImportExport::RepoSaver do
  describe 'bundle a project Git repo' do
    let_it_be(:user) { create(:user) }

    let!(:project) { create(:project, :repository) }
    let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" }
    let(:shared) { project.import_export_shared }
    let(:bundler) { described_class.new(exportable: project, shared: shared) }

    before do
      project.add_maintainer(user)
      allow_next_instance_of(Gitlab::ImportExport) do |instance|
        allow(instance).to receive(:storage_path).and_return(export_path)
      end
    end

    after do
      FileUtils.rm_rf(export_path)
    end

    it 'bundles the repo successfully' do
      expect(bundler.save).to be true
    end

    it 'creates the directory for the repository' do
      allow(bundler).to receive(:bundle_full_path).and_return('/foo/bar/file.tar.gz')

      expect(FileUtils).to receive(:mkdir_p).with('/foo/bar', anything)

      bundler.save # rubocop:disable Rails/SaveBang
    end

    context 'when the repo is empty' do
      let!(:project) { create(:project) }

      it 'bundles the repo successfully' do
        expect(bundler.save).to be true
      end
    end
  end
end