Add test for Project#protected_for?
This commit is contained in:
parent
554426ddca
commit
17c926313a
1 changed files with 37 additions and 0 deletions
|
@ -1796,6 +1796,43 @@ describe Project, models: true do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#protected_for?' do
|
||||
let(:project) { create(:empty_project) }
|
||||
|
||||
subject { project.protected_for?('ref') }
|
||||
|
||||
context 'when the ref is not protected' do
|
||||
before do
|
||||
stub_application_setting(
|
||||
default_branch_protection: Gitlab::Access::PROTECTION_NONE)
|
||||
end
|
||||
|
||||
it 'returns false' do
|
||||
is_expected.to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the ref is a protected branch' do
|
||||
before do
|
||||
create(:protected_branch, name: 'ref', project: project)
|
||||
end
|
||||
|
||||
it 'returns true' do
|
||||
is_expected.to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the ref is a protected tag' do
|
||||
before do
|
||||
create(:protected_tag, name: 'ref', project: project)
|
||||
end
|
||||
|
||||
it 'returns true' do
|
||||
is_expected.to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#update_project_statistics' do
|
||||
let(:project) { create(:empty_project) }
|
||||
|
||||
|
|
Loading…
Reference in a new issue