diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-02-22 13:56:38 -0300 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-02-22 13:59:15 -0300 |
commit | 45c77dacbc7d9d71e6a32feb0640400bd266c357 (patch) | |
tree | 128ca00f0bf1f0eed9ad3b57a41e1bf95b27aaf0 /app/presenters | |
parent | 31d1b2ca8c338281f3fac6dd862c988b721fa39d (diff) | |
download | gitlab-ce-45c77dacbc7d9d71e6a32feb0640400bd266c357.tar.gz |
Move can_current_user_push_to_branch to Presenter
Diffstat (limited to 'app/presenters')
-rw-r--r-- | app/presenters/project_presenter.rb | 8 |
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) }, |