Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
b8d8e4be
Commit
b8d8e4be
authored
Mar 05, 2020
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename validate method to align with other checker class
BaseChecker uses validate instead of exec
parent
25fddbf4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
12 deletions
+7
-12
lib/gitlab/checks/snippet_check.rb
lib/gitlab/checks/snippet_check.rb
+1
-4
lib/gitlab/git_access_snippet.rb
lib/gitlab/git_access_snippet.rb
+1
-3
spec/lib/gitlab/checks/snippet_check_spec.rb
spec/lib/gitlab/checks/snippet_check_spec.rb
+5
-5
No files found.
lib/gitlab/checks/snippet_check.rb
View file @
b8d8e4be
...
...
@@ -20,14 +20,11 @@ module Gitlab
@logger
.
append_message
(
"Running checks for ref:
#{
@branch_name
||
@tag_name
}
"
)
end
def
exec
def
validate!
if
creation?
||
deletion?
raise
GitAccess
::
ForbiddenError
,
ERROR_MESSAGES
[
:create_delete_branch
]
end
# TODO: https://gitlab.com/gitlab-org/gitlab/issues/205628
# Check operation will not result in more than one file in the repository
true
end
...
...
lib/gitlab/git_access_snippet.rb
View file @
b8d8e4be
...
...
@@ -97,9 +97,7 @@ module Gitlab
end
def
check_single_change_access
(
change
)
change_access
=
Checks
::
SnippetCheck
.
new
(
change
,
logger:
logger
)
change_access
.
exec
Checks
::
SnippetCheck
.
new
(
change
,
logger:
logger
).
validate!
rescue
Checks
::
TimedLogger
::
TimeoutError
raise
TimeoutError
,
logger
.
full_message
end
...
...
spec/lib/gitlab/checks/snippet_check_spec.rb
View file @
b8d8e4be
...
...
@@ -10,16 +10,16 @@ describe Gitlab::Checks::SnippetCheck do
subject
{
Gitlab
::
Checks
::
SnippetCheck
.
new
(
changes
,
logger:
logger
)
}
describe
'#
exec
'
do
describe
'#
validate!
'
do
it
'does not raise any error'
do
expect
{
subject
.
exec
}.
not_to
raise_error
expect
{
subject
.
validate!
}.
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
::
ForbiddenError
,
'You can not create or delete branches.'
)
expect
{
subject
.
validate!
}.
to
raise_error
(
Gitlab
::
GitAccess
::
ForbiddenError
,
'You can not create or delete branches.'
)
end
end
...
...
@@ -28,14 +28,14 @@ describe Gitlab::Checks::SnippetCheck do
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.'
)
expect
{
subject
.
validate!
}.
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
expect
{
subject
.
validate!
}.
not_to
raise_error
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment