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

force_push_spec.rb « checks « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8cdee727d3dea37342c8d42d468a4268fce9497b (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Checks::ForcePush do
  let_it_be(:project) { create(:project, :repository) }

  describe '.force_push?' do
    let(:old_rev) { 'HEAD~' }
    let(:new_rev) { 'HEAD' }

    subject(:force_push) { described_class.force_push?(project, old_rev, new_rev) }

    context 'when the repo is empty' do
      before do
        allow(project).to receive(:empty_repo?).and_return(true)
      end

      it 'returns false' do
        expect(force_push).to be(false)
      end
    end

    context 'when new rev is a descendant of old rev' do
      it 'returns false' do
        expect(force_push).to be(false)
      end
    end

    context 'when new rev is not a descendant of old rev' do
      let(:old_rev) { 'HEAD' }
      let(:new_rev) { 'HEAD~' }

      it 'returns true' do
        expect(force_push).to be(true)
      end
    end
  end
end