summaryrefslogtreecommitdiff
path: root/spec/models/protected_branch_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/protected_branch_spec.rb')
-rw-r--r--spec/models/protected_branch_spec.rb42
1 files changed, 21 insertions, 21 deletions
diff --git a/spec/models/protected_branch_spec.rb b/spec/models/protected_branch_spec.rb
index 4c677200ae2..3efe1baf4f6 100644
--- a/spec/models/protected_branch_spec.rb
+++ b/spec/models/protected_branch_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe ProtectedBranch do
subject { build_stubbed(:protected_branch) }
- describe 'Associations' do
+ describe "Associations" do
it { is_expected.to belong_to(:project) }
end
- describe 'Validation' do
+ describe "Validation" do
it { is_expected.to validate_presence_of(:project) }
it { is_expected.to validate_presence_of(:name) }
end
@@ -135,58 +135,58 @@ describe ProtectedBranch do
end
end
- describe '#protected?' do
- context 'existing project' do
+ describe "#protected?" do
+ context "existing project" do
let(:project) { create(:project, :repository) }
- it 'returns true when the branch matches a protected branch via direct match' do
+ it "returns true when the branch matches a protected branch via direct match" do
create(:protected_branch, project: project, name: "foo")
- expect(described_class.protected?(project, 'foo')).to eq(true)
+ expect(described_class.protected?(project, "foo")).to eq(true)
end
- it 'returns true when the branch matches a protected branch via wildcard match' do
+ it "returns true when the branch matches a protected branch via wildcard match" do
create(:protected_branch, project: project, name: "production/*")
- expect(described_class.protected?(project, 'production/some-branch')).to eq(true)
+ expect(described_class.protected?(project, "production/some-branch")).to eq(true)
end
- it 'returns false when the branch does not match a protected branch via direct match' do
- expect(described_class.protected?(project, 'foo')).to eq(false)
+ it "returns false when the branch does not match a protected branch via direct match" do
+ expect(described_class.protected?(project, "foo")).to eq(false)
end
- it 'returns false when the branch does not match a protected branch via wildcard match' do
+ it "returns false when the branch does not match a protected branch via wildcard match" do
create(:protected_branch, project: project, name: "production/*")
- expect(described_class.protected?(project, 'staging/some-branch')).to eq(false)
+ expect(described_class.protected?(project, "staging/some-branch")).to eq(false)
end
end
context "new project" do
let(:project) { create(:project) }
- it 'returns false when default_protected_branch is unprotected' do
+ it "returns false when default_protected_branch is unprotected" do
stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_NONE)
- expect(described_class.protected?(project, 'master')).to be false
+ expect(described_class.protected?(project, "master")).to be false
end
- it 'returns false when default_protected_branch lets developers push' do
+ it "returns false when default_protected_branch lets developers push" do
stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_DEV_CAN_PUSH)
- expect(described_class.protected?(project, 'master')).to be false
+ expect(described_class.protected?(project, "master")).to be false
end
- it 'returns true when default_branch_protection does not let developers push but let developer merge branches' do
+ it "returns true when default_branch_protection does not let developers push but let developer merge branches" do
stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_DEV_CAN_MERGE)
- expect(described_class.protected?(project, 'master')).to be true
+ expect(described_class.protected?(project, "master")).to be true
end
- it 'returns true when default_branch_protection is in full protection' do
+ it "returns true when default_branch_protection is in full protection" do
stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_FULL)
- expect(described_class.protected?(project, 'master')).to be true
+ expect(described_class.protected?(project, "master")).to be true
end
end
end