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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
0b5b3ec3
Commit
0b5b3ec3
authored
Jan 12, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove useless permission checks in Gitlab::Checks::ChangeAccess
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
bf073583
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
5 deletions
+2
-5
lib/gitlab/checks/change_access.rb
lib/gitlab/checks/change_access.rb
+2
-2
spec/lib/gitlab/checks/change_access_spec.rb
spec/lib/gitlab/checks/change_access_spec.rb
+0
-3
No files found.
lib/gitlab/checks/change_access.rb
View file @
0b5b3ec3
...
@@ -30,9 +30,9 @@ module Gitlab
...
@@ -30,9 +30,9 @@ module Gitlab
return
unless
@branch_name
return
unless
@branch_name
return
unless
project
.
protected_branch?
(
@branch_name
)
return
unless
project
.
protected_branch?
(
@branch_name
)
if
forced_push?
&&
user_access
.
cannot_do_action?
(
:force_push_code_to_protected_branches
)
if
forced_push?
return
"You are not allowed to force push code to a protected branch on this project."
return
"You are not allowed to force push code to a protected branch on this project."
elsif
Gitlab
::
Git
.
blank_ref?
(
@newrev
)
&&
user_access
.
cannot_do_action?
(
:remove_protected_branches
)
elsif
Gitlab
::
Git
.
blank_ref?
(
@newrev
)
return
"You are not allowed to delete protected branches from this project."
return
"You are not allowed to delete protected branches from this project."
end
end
...
...
spec/lib/gitlab/checks/change_access_spec.rb
View file @
0b5b3ec3
...
@@ -56,7 +56,6 @@ describe Gitlab::Checks::ChangeAccess, lib: true do
...
@@ -56,7 +56,6 @@ describe Gitlab::Checks::ChangeAccess, lib: true do
it
'returns an error if the user is not allowed to do forced pushes to protected branches'
do
it
'returns an error if the user is not allowed to do forced pushes to protected branches'
do
expect
(
Gitlab
::
Checks
::
ForcePush
).
to
receive
(
:force_push?
).
and_return
(
true
)
expect
(
Gitlab
::
Checks
::
ForcePush
).
to
receive
(
:force_push?
).
and_return
(
true
)
expect
(
user_access
).
to
receive
(
:can_do_action?
).
with
(
:force_push_code_to_protected_branches
).
and_return
(
false
)
expect
(
subject
.
status
).
to
be
(
false
)
expect
(
subject
.
status
).
to
be
(
false
)
expect
(
subject
.
message
).
to
eq
(
'You are not allowed to force push code to a protected branch on this project.'
)
expect
(
subject
.
message
).
to
eq
(
'You are not allowed to force push code to a protected branch on this project.'
)
...
@@ -88,8 +87,6 @@ describe Gitlab::Checks::ChangeAccess, lib: true do
...
@@ -88,8 +87,6 @@ describe Gitlab::Checks::ChangeAccess, lib: true do
end
end
it
'returns an error if the user is not allowed to delete protected branches'
do
it
'returns an error if the user is not allowed to delete protected branches'
do
expect
(
user_access
).
to
receive
(
:can_do_action?
).
with
(
:remove_protected_branches
).
and_return
(
false
)
expect
(
subject
.
status
).
to
be
(
false
)
expect
(
subject
.
status
).
to
be
(
false
)
expect
(
subject
.
message
).
to
eq
(
'You are not allowed to delete protected branches from this project.'
)
expect
(
subject
.
message
).
to
eq
(
'You are not allowed to delete protected branches from this project.'
)
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