Read about our upcoming Code of Conduct on this issue

namespace_export_file_spec.rb 1.62 KB
Newer Older
1
2
require 'spec_helper'

Nick Thomas's avatar
Nick Thomas committed
3
describe 'Import/Export - Namespace export file cleanup', :js do
4
  let(:export_path) { Dir.mktmpdir('namespace_export_file_spec') }
5

6
7
  before do
    allow(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path)
8
    stub_feature_flags(import_export_object_storage: false)
9
10
11
12
13
14
  end

  after do
    FileUtils.rm_rf(export_path, secure: true)
  end

15
16
17
  shared_examples_for 'handling project exports on namespace change' do
    let!(:old_export_path) { project.export_path }

18
    before do
19
      sign_in(create(:admin))
20
21

      setup_export_project
22
23
24
    end

    context 'moving the namespace' do
25
      it 'removes the export file' do
26
27
        expect(File).to exist(old_export_path)

28
        project.namespace.update!(path: build(:namespace).path)
29
30
31
32
33
34

        expect(File).not_to exist(old_export_path)
      end
    end

    context 'deleting the namespace' do
35
      it 'removes the export file' do
36
37
38
39
40
41
42
        expect(File).to exist(old_export_path)

        project.namespace.destroy

        expect(File).not_to exist(old_export_path)
      end
    end
43
  end
44

45
  describe 'legacy storage' do
Nick Thomas's avatar
Nick Thomas committed
46
    let(:project) { create(:project, :legacy_storage) }
47

48
49
50
51
    it_behaves_like 'handling project exports on namespace change'
  end

  describe 'hashed storage' do
Nick Thomas's avatar
Nick Thomas committed
52
    let(:project) { create(:project) }
53

54
55
    it_behaves_like 'handling project exports on namespace change'
  end
56

57
58
  def setup_export_project
    visit edit_project_path(project)
59

60
61
62
63
64
65
66
    expect(page).to have_content('Export project')

    find(:link, 'Export project').send_keys(:return)

    visit edit_project_path(project)

    expect(page).to have_content('Download export')
67
68
  end
end