summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/source_spec.rb
blob: c2ecb4dfb853eab8ffaafd769148003e3dfcf797 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Source, feature_category: :shared do
  include StubVersion

  describe '.ref' do
    subject(:ref) { described_class.ref }

    context 'when not on a pre-release' do
      before do
        stub_version('15.0.0-ee', 'a123a123')
      end

      it { is_expected.to eq('v15.0.0-ee') }
    end

    context 'when on a pre-release' do
      before do
        stub_version('15.0.0-pre', 'a123a123')
      end

      it { is_expected.to eq('a123a123') }
    end
  end

  describe '.release_url' do
    subject(:release_url) { described_class.release_url }

    context 'when not on a pre-release' do
      before do
        stub_version('15.0.0-ee', 'a123a123')
      end

      it 'returns a tag url' do
        expect(release_url).to match("https://gitlab.com/gitlab-org/gitlab(-foss)?/-/tags/v15.0.0-ee")
      end
    end

    context 'when on a pre-release' do
      before do
        stub_version('15.0.0-pre', 'a123a123')
      end

      it 'returns a commit url' do
        expect(release_url).to match("https://gitlab.com/gitlab-org/gitlab(-foss)?/-/commits/a123a123")
      end
    end
  end
end