BigW Consortium Gitlab

project_transfer_spec.rb 1.67 KB
Newer Older
1 2
require 'spec_helper'

3
describe Gitlab::ProjectTransfer do
4 5
  before do
    @root_dir = File.join(Rails.root, "public", "uploads")
6
    @project_transfer = described_class.new
7
    allow(@project_transfer).to receive(:root_dir).and_return(@root_dir)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

    @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))
25
      @project_transfer.move_project(@project_path, @namespace_path_was, @namespace_path)
26 27 28 29 30 31 32 33 34

      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))
35
      @project_transfer.rename_project(@project_path_was, @project_path, @namespace_path)
36 37 38 39 40 41 42 43 44

      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))
45
      @project_transfer.rename_namespace(@namespace_path_was, @namespace_path)
46 47 48 49 50 51

      expected_path = File.join(@root_dir, @namespace_path, @project_path)
      expect(Dir.exist?(expected_path)).to be_truthy
    end
  end
end