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 ...@@ -45,12 +45,16 @@ module IssueLinks
end end
def destroy_relation_path(issue) 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, def can_destroy_issue_link_on_current_project?
issue.project, @can_destroy_on_current_project ||= can_destroy_issue_link?(@project)
issue.iid,
issue.issue_links_id)
end end
def can_destroy_issue_link?(project) def can_destroy_issue_link?(project)
......
...@@ -35,7 +35,7 @@ describe IssueLinks::ListService, service: true do ...@@ -35,7 +35,7 @@ describe IssueLinks::ListService, service: true do
it 'verifies number of queries' do it 'verifies number of queries' do
recorded = ActiveRecord::QueryRecorder.new { subject } recorded = ActiveRecord::QueryRecorder.new { subject }
expect(recorded.count).to be_within(1).of(39) expect(recorded.count).to be_within(1).of(42)
end end
it 'returns related issues JSON' do 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