summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/access/branch_protection_spec.rb
blob: 9b736a30c7ead717dc00d7f000029094ee1b562b (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
65
66
67
68
69
70
71
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Access::BranchProtection do
  describe '#any?' do
    using RSpec::Parameterized::TableSyntax

    where(:level, :result) do
      Gitlab::Access::PROTECTION_NONE          | false
      Gitlab::Access::PROTECTION_DEV_CAN_PUSH  | true
      Gitlab::Access::PROTECTION_DEV_CAN_MERGE | true
      Gitlab::Access::PROTECTION_FULL          | true
    end

    with_them do
      it { expect(described_class.new(level).any?).to eq(result) }
    end
  end

  describe '#developer_can_push?' do
    using RSpec::Parameterized::TableSyntax

    where(:level, :result) do
      Gitlab::Access::PROTECTION_NONE          | false
      Gitlab::Access::PROTECTION_DEV_CAN_PUSH  | true
      Gitlab::Access::PROTECTION_DEV_CAN_MERGE | false
      Gitlab::Access::PROTECTION_FULL          | false
    end

    with_them do
      it do
        expect(described_class.new(level).developer_can_push?).to eq(result)
      end
    end
  end

  describe '#developer_can_merge?' do
    using RSpec::Parameterized::TableSyntax

    where(:level, :result) do
      Gitlab::Access::PROTECTION_NONE          | false
      Gitlab::Access::PROTECTION_DEV_CAN_PUSH  | false
      Gitlab::Access::PROTECTION_DEV_CAN_MERGE | true
      Gitlab::Access::PROTECTION_FULL          | false
    end

    with_them do
      it do
        expect(described_class.new(level).developer_can_merge?).to eq(result)
      end
    end
  end

  describe '#fully_protected?' do
    using RSpec::Parameterized::TableSyntax

    where(:level, :result) do
      Gitlab::Access::PROTECTION_NONE          | false
      Gitlab::Access::PROTECTION_DEV_CAN_PUSH  | false
      Gitlab::Access::PROTECTION_DEV_CAN_MERGE | false
      Gitlab::Access::PROTECTION_FULL          | true
    end

    with_them do
      it do
        expect(described_class.new(level).fully_protected?).to eq(result)
      end
    end
  end
end