2015-10-06 14:09:03 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 14:24:02 +00:00
|
|
|
describe Gitlab::ProjectTransfer do
|
2015-10-06 14:09:03 +00:00
|
|
|
before do
|
|
|
|
@root_dir = File.join(Rails.root, "public", "uploads")
|
2017-07-25 17:09:00 +00:00
|
|
|
@project_transfer = described_class.new
|
2015-12-18 11:40:34 +00:00
|
|
|
allow(@project_transfer).to receive(:root_dir).and_return(@root_dir)
|
2015-10-06 14:09:03 +00:00
|
|
|
|
|
|
|
@project_path_was = "test_project_was"
|
|
|
|
@project_path = "test_project"
|
|
|
|
@namespace_path_was = "test_namespace_was"
|
|
|
|
@namespace_path = "test_namespace"
|
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
|
|
|
FileUtils.rm_rf([
|
|
|
|
File.join(@root_dir, @namespace_path),
|
|
|
|
File.join(@root_dir, @namespace_path_was)
|
|
|
|
])
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#move_project' do
|
|
|
|
it "moves project upload to another namespace" do
|
|
|
|
FileUtils.mkdir_p(File.join(@root_dir, @namespace_path_was, @project_path))
|
2015-12-18 11:40:34 +00:00
|
|
|
@project_transfer.move_project(@project_path, @namespace_path_was, @namespace_path)
|
2015-10-06 14:09:03 +00:00
|
|
|
|
|
|
|
expected_path = File.join(@root_dir, @namespace_path, @project_path)
|
|
|
|
expect(Dir.exist?(expected_path)).to be_truthy
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#rename_project' do
|
|
|
|
it "renames project" do
|
|
|
|
FileUtils.mkdir_p(File.join(@root_dir, @namespace_path, @project_path_was))
|
2015-12-18 11:40:34 +00:00
|
|
|
@project_transfer.rename_project(@project_path_was, @project_path, @namespace_path)
|
2015-10-06 14:09:03 +00:00
|
|
|
|
|
|
|
expected_path = File.join(@root_dir, @namespace_path, @project_path)
|
|
|
|
expect(Dir.exist?(expected_path)).to be_truthy
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#rename_namespace' do
|
|
|
|
it "renames namespace" do
|
|
|
|
FileUtils.mkdir_p(File.join(@root_dir, @namespace_path_was, @project_path))
|
2015-12-18 11:40:34 +00:00
|
|
|
@project_transfer.rename_namespace(@namespace_path_was, @namespace_path)
|
2015-10-06 14:09:03 +00:00
|
|
|
|
|
|
|
expected_path = File.join(@root_dir, @namespace_path, @project_path)
|
|
|
|
expect(Dir.exist?(expected_path)).to be_truthy
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|