Commit c1df6a44 authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Memoize "destroy issue link on current project" permission

parent 7678e702
......@@ -45,12 +45,16 @@ module IssueLinks
end
def destroy_relation_path(issue)
return unless can_destroy_issue_link?(@project) && can_destroy_issue_link?(issue.project)
if can_destroy_issue_link_on_current_project? && can_destroy_issue_link?(issue.project)
namespace_project_issue_link_path(issue.project.namespace,
issue.project,
issue.iid,
issue.issue_links_id)
end
end
namespace_project_issue_link_path(issue.project.namespace,
issue.project,
issue.iid,
issue.issue_links_id)
def can_destroy_issue_link_on_current_project?
@can_destroy_on_current_project ||= can_destroy_issue_link?(@project)
end
def can_destroy_issue_link?(project)
......
......@@ -35,7 +35,7 @@ describe IssueLinks::ListService, service: true do
it 'verifies number of queries' do
recorded = ActiveRecord::QueryRecorder.new { subject }
expect(recorded.count).to be_within(1).of(39)
expect(recorded.count).to be_within(1).of(42)
end
it 'returns related issues JSON' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment