Welcome to mirror list, hosted at ThFree Co, Russian Federation.

repo_path_spec.rb « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f94c9c2e3155f146b376775d8f0b95c8eb46bc38 (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
require 'spec_helper'

describe ::Gitlab::RepoPath do
  describe '.parse' do
    set(:project) { create(:project) }

    it 'parses a full repository path' do
      expect(described_class.parse(project.repository.path)).to eq([project, false])
    end

    it 'parses a full wiki path' do
      expect(described_class.parse(project.wiki.repository.path)).to eq([project, true])
    end

    it 'parses a relative repository path' do
      expect(described_class.parse(project.full_path + '.git')).to eq([project, false])
    end

    it 'parses a relative wiki path' do
      expect(described_class.parse(project.full_path + '.wiki.git')).to eq([project, true])
    end

    it 'parses a relative path starting with /' do
      expect(described_class.parse('/' + project.full_path + '.git')).to eq([project, false])
    end
  end

  describe '.strip_storage_path' do
    before do
      allow(Gitlab.config.repositories).to receive(:storages).and_return({
        'storage1' => { 'path' => '/foo' },
        'storage2' => { 'path' => '/bar' },
      })
    end

    it 'strips the storage path' do
      expect(described_class.strip_storage_path('/bar/foo/qux/baz.git')).to eq('foo/qux/baz.git')
    end

    it 'raises NotFoundError if no storage matches the path' do
      expect { described_class.strip_storage_path('/doesnotexist/foo.git') }.to raise_error(
        described_class::NotFoundError
      )
    end
  end
end