summaryrefslogtreecommitdiff
path: root/spec/models/protectable_dropdown_spec.rb
blob: 5c5dcd9f5c9950e9557a465cfc105f47dc3ca2fd (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
require 'spec_helper'

describe ProtectableDropdown do
  let(:project) { create(:project, :repository) }
  let(:subject) { described_class.new(project, :branches) }

  describe '#protectable_ref_names' do
    before do
      project.protected_branches.create(name: 'master')
    end

    it { expect(subject.protectable_ref_names).to include('feature') }
    it { expect(subject.protectable_ref_names).not_to include('master') }

    it "includes branches matching a protected branch wildcard" do
      expect(subject.protectable_ref_names).to include('feature')

      create(:protected_branch, name: 'feat*', project: project)

      subject = described_class.new(project.reload, :branches)

      expect(subject.protectable_ref_names).to include('feature')
    end
  end
end