summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/checks/force_push_spec.rb
blob: 334dd8635a395dd2284f0b9f048c37ce04dae970 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

require 'spec_helper'

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

  describe '.force_push?' do
    it 'returns false if the repo is empty' do
      allow(project).to receive(:empty_repo?).and_return(true)

      expect(described_class.force_push?(project, 'HEAD', 'HEAD~')).to be(false)
    end

    it 'checks if old rev is an anchestor' do
      expect(described_class.force_push?(project, 'HEAD', 'HEAD~')).to be(true)
    end
  end
end