Commit 98e21104 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'fj-allow-create-snippet-default-branch' into 'master'

Allow creating default branch in snippet repositories

Closes #208701

See merge request gitlab-org/gitlab!26294
parents 3023279e 5f6dc362
---
title: Allow creating default branch in snippet repositories
merge_request: 26294
author:
type: fixed
......@@ -3,6 +3,7 @@
module Gitlab
module Checks
class SnippetCheck < BaseChecker
DEFAULT_BRANCH = 'master'.freeze
ERROR_MESSAGES = {
create_delete_branch: 'You can not create or delete branches.'
}.freeze
......@@ -29,6 +30,12 @@ module Gitlab
true
end
private
def creation?
@branch_name != DEFAULT_BRANCH && super
end
end
end
end
......@@ -25,10 +25,19 @@ describe Gitlab::Checks::SnippetCheck do
context 'trying to create the branch' do
let(:oldrev) { '0000000000000000000000000000000000000000' }
let(:ref) { 'refs/heads/feature' }
it 'raises an error' do
expect { subject.exec }.to raise_error(Gitlab::GitAccess::ForbiddenError, 'You can not create or delete branches.')
end
context "when branch is 'master'" do
let(:ref) { 'refs/heads/master' }
it "allows the operation" do
expect { subject.exec }.not_to raise_error
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment