2017-08-17 22:00:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
feature 'Import/Export - Namespace export file cleanup', :js do
|
|
|
|
let(:export_path) { Dir.mktmpdir('namespace_export_file_spec') }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
before do
|
|
|
|
allow(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
|
|
|
FileUtils.rm_rf(export_path, secure: true)
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
shared_examples_for 'handling project exports on namespace change' do
|
|
|
|
let!(:old_export_path) { project.export_path }
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
before do
|
2017-09-10 17:25:29 +05:30
|
|
|
sign_in(create(:admin))
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
setup_export_project
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'moving the namespace' do
|
2018-03-17 18:26:18 +05:30
|
|
|
it 'removes the export file' do
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(File).to exist(old_export_path)
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
project.namespace.update!(path: build(:namespace).path)
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
expect(File).not_to exist(old_export_path)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'deleting the namespace' do
|
2018-03-17 18:26:18 +05:30
|
|
|
it 'removes the export file' do
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(File).to exist(old_export_path)
|
|
|
|
|
|
|
|
project.namespace.destroy
|
|
|
|
|
|
|
|
expect(File).not_to exist(old_export_path)
|
|
|
|
end
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
describe 'legacy storage' do
|
|
|
|
let(:project) { create(:project) }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
it_behaves_like 'handling project exports on namespace change'
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'hashed storage' do
|
|
|
|
let(:project) { create(:project, :hashed) }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
it_behaves_like 'handling project exports on namespace change'
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
def setup_export_project
|
|
|
|
visit edit_project_path(project)
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
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')
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|