summaryrefslogtreecommitdiff
path: root/spec/models/protectable_dropdown_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/protectable_dropdown_spec.rb')
-rw-r--r--spec/models/protectable_dropdown_spec.rb32
1 files changed, 22 insertions, 10 deletions
diff --git a/spec/models/protectable_dropdown_spec.rb b/spec/models/protectable_dropdown_spec.rb
index c51197234ca..918c3078405 100644
--- a/spec/models/protectable_dropdown_spec.rb
+++ b/spec/models/protectable_dropdown_spec.rb
@@ -14,21 +14,33 @@ RSpec.describe ProtectableDropdown do
end
describe '#protectable_ref_names' do
- before do
- project.protected_branches.create(name: 'master')
- end
+ context 'when project repository is not empty' 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')
- it { expect(subject.protectable_ref_names).to include('feature') }
- it { expect(subject.protectable_ref_names).not_to include('master') }
+ create(:protected_branch, name: 'feat*', project: project)
- it "includes branches matching a protected branch wildcard" do
- expect(subject.protectable_ref_names).to include('feature')
+ subject = described_class.new(project.reload, :branches)
+
+ expect(subject.protectable_ref_names).to include('feature')
+ end
+ end
- create(:protected_branch, name: 'feat*', project: project)
+ context 'when project repository is empty' do
+ let(:project) { create(:project) }
- subject = described_class.new(project.reload, :branches)
+ it "returns empty list" do
+ subject = described_class.new(project, :branches)
- expect(subject.protectable_ref_names).to include('feature')
+ expect(subject.protectable_ref_names).to be_empty
+ end
end
end
end