diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-02-07 19:32:32 +0300 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-02-07 21:29:27 +0300 |
commit | dfe9f0bc6ed38363c7e6c01bf95b42f3e5c0166b (patch) | |
tree | dbac868ce52fb5782f3e40adf073ae5e69c571d2 /app/presenters/merge_request_presenter.rb | |
parent | 6441612614fd5b89c7990010b9ba4734dbfe8ef1 (diff) |
Remove duplicate calls of MergeRequest#can_be_reverted?
Diffstat (limited to 'app/presenters/merge_request_presenter.rb')
-rw-r--r-- | app/presenters/merge_request_presenter.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/app/presenters/merge_request_presenter.rb b/app/presenters/merge_request_presenter.rb index c6806b7cc26..c1b4429bd0c 100644 --- a/app/presenters/merge_request_presenter.rb +++ b/app/presenters/merge_request_presenter.rb @@ -3,6 +3,7 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated include GitlabRoutingHelper include MarkupHelper include TreeHelper + include Gitlab::Utils::StrongMemoize presents :merge_request @@ -43,7 +44,7 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated end def revert_in_fork_path - if user_can_fork_project? && can_be_reverted?(current_user) + if user_can_fork_project? && _can_be_reverted? continue_params = { to: merge_request_path(merge_request), notice: "#{edit_in_new_fork_notice} Try to cherry-pick this commit again.", @@ -151,7 +152,7 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated end def can_revert_on_current_merge_request? - user_can_collaborate_with_project? && can_be_reverted?(current_user) + user_can_collaborate_with_project? && _can_be_reverted? end def can_cherry_pick_on_current_merge_request? @@ -164,6 +165,13 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated private + # Method overrides doesn't work for Gitlab::View::Presenter::Delegated + def _can_be_reverted? + strong_memoize(:can_be_reverted) do + can_be_reverted?(current_user) + end + end + def conflicts @conflicts ||= MergeRequests::Conflicts::ListService.new(merge_request) end |