Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-27 18:09:24 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-27 18:09:24 +0300
commitf8d15ca65390475e356b06dedc51e10ccd179f86 (patch)
treeef916d4e8e11c9e00d809e5cdcf63814e86d6e89 /spec/lib/gitlab/checks
parent3ab4feda4dce9c9f0672375ae27c2f7c2ba6f4ad (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/checks')
-rw-r--r--spec/lib/gitlab/checks/snippet_check_spec.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/lib/gitlab/checks/snippet_check_spec.rb b/spec/lib/gitlab/checks/snippet_check_spec.rb
new file mode 100644
index 00000000000..7cb29debd1e
--- /dev/null
+++ b/spec/lib/gitlab/checks/snippet_check_spec.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Gitlab::Checks::SnippetCheck do
+ include_context 'change access checks context'
+
+ let(:snippet) { create(:personal_snippet, :repository) }
+ let(:user_access) { Gitlab::UserAccessSnippet.new(user, snippet: snippet) }
+
+ subject { Gitlab::Checks::SnippetCheck.new(changes, logger: logger) }
+
+ describe '#exec' do
+ it 'does not raise any error' do
+ expect { subject.exec }.not_to raise_error
+ end
+
+ context 'trying to delete the branch' do
+ let(:newrev) { '0000000000000000000000000000000000000000' }
+
+ it 'raises an error' do
+ expect { subject.exec }.to raise_error(Gitlab::GitAccess::UnauthorizedError, 'You can not create or delete branches.')
+ end
+ end
+
+ context 'trying to create the branch' do
+ let(:oldrev) { '0000000000000000000000000000000000000000' }
+
+ it 'raises an error' do
+ expect { subject.exec }.to raise_error(Gitlab::GitAccess::UnauthorizedError, 'You can not create or delete branches.')
+ end
+ end
+ end
+end