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:
authorOswaldo Ferreira <oswaldo@gitlab.com>2018-02-22 19:56:38 +0300
committerOswaldo Ferreira <oswaldo@gitlab.com>2018-02-22 19:59:15 +0300
commit45c77dacbc7d9d71e6a32feb0640400bd266c357 (patch)
tree128ca00f0bf1f0eed9ad3b57a41e1bf95b27aaf0 /app/presenters
parent31d1b2ca8c338281f3fac6dd862c988b721fa39d (diff)
Move can_current_user_push_to_branch to Presenter
Diffstat (limited to 'app/presenters')
-rw-r--r--app/presenters/project_presenter.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/presenters/project_presenter.rb b/app/presenters/project_presenter.rb
index f850f6273a3..9db4ef63fd7 100644
--- a/app/presenters/project_presenter.rb
+++ b/app/presenters/project_presenter.rb
@@ -164,11 +164,17 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
if empty_repo?
can?(current_user, :push_code, project)
else
- user_can_push_to_branch?(current_user, default_branch)
+ can_current_user_push_to_branch?(default_branch)
end
end
end
+ def can_current_user_push_to_branch?(branch)
+ return false unless repository.branch_exists?(branch)
+
+ ::Gitlab::UserAccess.new(current_user, project: project).can_push_to_branch?(branch)
+ end
+
def files_anchor_data
OpenStruct.new(enabled: true,
label: _('Files (%{human_size})') % { human_size: storage_counter(statistics.total_repository_size) },