summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/bare_repository_import/repository_spec.rb
blob: 61b73abcba4360bbcef67935f841f5c7f4b5ea92 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
require 'spec_helper'

describe ::Gitlab::BareRepositoryImport::Repository do
  let(:project_repo_path) { described_class.new('/full/path/', '/full/path/to/repo.git') }

  it 'stores the repo path' do
    expect(project_repo_path.repo_path).to eq('/full/path/to/repo.git')
  end

  it 'stores the group path' do
    expect(project_repo_path.group_path).to eq('to')
  end

  it 'stores the project name' do
    expect(project_repo_path.project_name).to eq('repo')
  end

  it 'stores the wiki path' do
    expect(project_repo_path.wiki_path).to eq('/full/path/to/repo.wiki.git')
  end

  describe '#wiki?' do
    it 'returns true if it is a wiki' do
      wiki_path = described_class.new('/full/path/', '/full/path/to/a/b/my.wiki.git')

      expect(wiki_path.wiki?).to eq(true)
    end

    it 'returns false if it is not a wiki' do
      expect(project_repo_path.wiki?).to eq(false)
    end
  end

  describe '#hashed?' do
    it 'returns true if it is a hashed folder' do
      path = described_class.new('/full/path/', '/full/path/@hashed/my.repo.git')

      expect(path.hashed?).to eq(true)
    end

    it 'returns false if it is not a hashed folder' do
      expect(project_repo_path.hashed?).to eq(false)
    end
  end

  describe '#project_full_path' do
    it 'returns the project full path' do
      expect(project_repo_path.repo_path).to eq('/full/path/to/repo.git')
      expect(project_repo_path.project_full_path).to eq('to/repo')
    end

    it 'with no trailing slash in the root path' do
      repo_path = described_class.new('/full/path', '/full/path/to/repo.git')

      expect(repo_path.project_full_path).to eq('to/repo')
    end
  end
end