summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-01-12 17:37:14 -0500
committerRémy Coutable <remy@rymai.me>2017-01-12 17:37:14 -0500
commit0b5b3ec3a432842bc53c7226c6db98e484aeee50 (patch)
tree5e72f4916f8a681c29bd4b40351b39ec62a1394b
parentbf073583fba475382a927b8f35df6514d4bcb88f (diff)
downloadgitlab-ce-25018-gitlab-checks-changeaccess-looks-for-user-permissions-that-don-t-exist.tar.gz
Remove useless permission checks in Gitlab::Checks::ChangeAccess25018-gitlab-checks-changeaccess-looks-for-user-permissions-that-don-t-exist
Signed-off-by: Rémy Coutable <remy@rymai.me>
-rw-r--r--lib/gitlab/checks/change_access.rb4
-rw-r--r--spec/lib/gitlab/checks/change_access_spec.rb3
2 files changed, 2 insertions, 5 deletions
diff --git a/lib/gitlab/checks/change_access.rb b/lib/gitlab/checks/change_access.rb
index 9c391fa92a3..273118135a9 100644
--- a/lib/gitlab/checks/change_access.rb
+++ b/lib/gitlab/checks/change_access.rb
@@ -30,9 +30,9 @@ module Gitlab
return unless @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."
- 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."
end
diff --git a/spec/lib/gitlab/checks/change_access_spec.rb b/spec/lib/gitlab/checks/change_access_spec.rb
index 39069b49978..98effecdbbc 100644
--- a/spec/lib/gitlab/checks/change_access_spec.rb
+++ b/spec/lib/gitlab/checks/change_access_spec.rb
@@ -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
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.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
end
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.message).to eq('You are not allowed to delete protected branches from this project.')
end