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

repo_type_spec.rb « gl_repository « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f06a2448ff72b451c1c4a72fb64ad56a9336b4f9 (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
59
60
61
62
63
64
# frozen_string_literal: true
require 'spec_helper'

describe Gitlab::GlRepository::RepoType do
  set(:project) { create(:project) }

  shared_examples 'a repo type' do
    describe "#identifier_for_subject" do
      subject { described_class.identifier_for_subject(project) }

      it { is_expected.to eq(expected_identifier) }
    end

    describe "#fetch_id" do
      it "finds an id match in the identifier" do
        expect(described_class.fetch_id(expected_identifier)).to eq(expected_id)
      end

      it 'does not break on other identifiers' do
        expect(described_class.fetch_id("wiki-noid")).to eq(nil)
      end
    end

    describe "#path_suffix" do
      subject { described_class.path_suffix }

      it { is_expected.to eq(expected_suffix) }
    end

    describe "#repository_for" do
      it "finds the repository for the repo type" do
        expect(described_class.repository_for(project)).to eq(expected_repository)
      end
    end
  end

  describe Gitlab::GlRepository::PROJECT do
    it_behaves_like 'a repo type' do
      let(:expected_identifier) { "project-#{project.id}" }
      let(:expected_id) { project.id.to_s }
      let(:expected_suffix) { "" }
      let(:expected_repository) { project.repository }
    end

    it "knows its type" do
      expect(described_class).not_to be_wiki
      expect(described_class).to be_project
    end
  end

  describe Gitlab::GlRepository::WIKI do
    it_behaves_like 'a repo type' do
      let(:expected_identifier) { "wiki-#{project.id}" }
      let(:expected_id) { project.id.to_s }
      let(:expected_suffix) { ".wiki" }
      let(:expected_repository) { project.wiki.repository }
    end

    it "knows its type" do
      expect(described_class).to be_wiki
      expect(described_class).not_to be_project
    end
  end
end