| ... | @@ -108,7 +108,28 @@ describe Gitlab::Checks::BranchCheck do |
... | @@ -108,7 +108,28 @@ describe Gitlab::Checks::BranchCheck do |
|
|
end
|
|
end
|
|
|
|
|
|
|
|
context 'protected branch creation feature is enabled' do
|
|
context 'protected branch creation feature is enabled' do
|
|
|
context 'user is not allowed to create protected branches' do
|
|
context 'user can push to branch' do
|
|
|
|
before do
|
|
|
|
allow(user_access)
|
|
|
|
.to receive(:can_push_to_branch?)
|
|
|
|
.with('feature')
|
|
|
|
.and_return(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not raise an error' do
|
|
|
|
expect { subject.validate! }.not_to raise_error
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'user cannot push to branch' do
|
|
|
|
before do
|
|
|
|
allow(user_access)
|
|
|
|
.to receive(:can_push_to_branch?)
|
|
|
|
.with('feature')
|
|
|
|
.and_return(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'user cannot merge to branch' do
|
|
|
before do
|
|
before do
|
|
|
allow(user_access)
|
|
allow(user_access)
|
|
|
.to receive(:can_merge_to_branch?)
|
|
.to receive(:can_merge_to_branch?)
|
| ... | @@ -121,7 +142,7 @@ describe Gitlab::Checks::BranchCheck do |
... | @@ -121,7 +142,7 @@ describe Gitlab::Checks::BranchCheck do |
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
context 'user is allowed to create protected branches' do
|
|
context 'user can merge to branch' do
|
|
|
before do
|
|
before do
|
|
|
allow(user_access)
|
|
allow(user_access)
|
|
|
.to receive(:can_merge_to_branch?)
|
|
.to receive(:can_merge_to_branch?)
|
| ... | @@ -172,6 +193,7 @@ describe Gitlab::Checks::BranchCheck do |
... | @@ -172,6 +193,7 @@ describe Gitlab::Checks::BranchCheck do |
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'branch deletion' do
|
|
context 'branch deletion' do
|
|
|
let(:newrev) { '0000000000000000000000000000000000000000' }
|
|
let(:newrev) { '0000000000000000000000000000000000000000' }
|
| ... | |
... | |
| ... | | ... | |