Commit 2e1b4505 authored by Thong Kuah's avatar Thong Kuah

Merge branch 'improve-preloading-issuable-parsers' into 'master'

Removes unneeded preloading in Markdown rendering

See merge request gitlab-org/gitlab!62273
parents c36dbef1 c264427e
...@@ -66,14 +66,7 @@ module Banzai ...@@ -66,14 +66,7 @@ module Banzai
# These associations are primarily used for checking permissions. # These associations are primarily used for checking permissions.
# Eager loading these ensures we don't end up running dozens of # Eager loading these ensures we don't end up running dozens of
# queries in this process. # queries in this process.
project: [ project: [:namespace, :project_feature, :route]
{ namespace: :owner },
{ group: [:owners, :group_members] },
:invited_groups,
:project_members,
:project_feature,
:route
]
} }
), ),
self.class.data_attribute self.class.data_attribute
......
...@@ -17,14 +17,7 @@ module Banzai ...@@ -17,14 +17,7 @@ module Banzai
# These associations are primarily used for checking permissions. # These associations are primarily used for checking permissions.
# Eager loading these ensures we don't end up running dozens of # Eager loading these ensures we don't end up running dozens of
# queries in this process. # queries in this process.
target_project: [ target_project: [{ namespace: :route }, :project_feature, :route]
{ namespace: [:owner, :route] },
{ group: [:owners, :group_members] },
:invited_groups,
:project_members,
:project_feature,
:route
]
}), }),
self.class.data_attribute self.class.data_attribute
) )
......
...@@ -5,9 +5,11 @@ require 'spec_helper' ...@@ -5,9 +5,11 @@ require 'spec_helper'
RSpec.describe Banzai::ReferenceParser::IssueParser do RSpec.describe Banzai::ReferenceParser::IssueParser do
include ReferenceParserHelpers include ReferenceParserHelpers
let(:project) { create(:project, :public) } let_it_be(:group) { create(:group, :public) }
let(:user) { create(:user) } let_it_be(:project) { create(:project, :public, group: group) }
let(:issue) { create(:issue, project: project) } let_it_be(:user) { create(:user) }
let_it_be(:issue) { create(:issue, project: project) }
let(:link) { empty_html_link } let(:link) { empty_html_link }
subject { described_class.new(Banzai::RenderContext.new(project, user)) } subject { described_class.new(Banzai::RenderContext.new(project, user)) }
...@@ -121,7 +123,7 @@ RSpec.describe Banzai::ReferenceParser::IssueParser do ...@@ -121,7 +123,7 @@ RSpec.describe Banzai::ReferenceParser::IssueParser do
end end
end end
context 'when checking multiple merge requests on another project' do context 'when checking multiple issues on another project' do
let(:other_project) { create(:project, :public) } let(:other_project) { create(:project, :public) }
let(:other_issue) { create(:issue, project: other_project) } let(:other_issue) { create(:issue, project: other_project) }
......
...@@ -5,9 +5,11 @@ require 'spec_helper' ...@@ -5,9 +5,11 @@ require 'spec_helper'
RSpec.describe Banzai::ReferenceParser::MergeRequestParser do RSpec.describe Banzai::ReferenceParser::MergeRequestParser do
include ReferenceParserHelpers include ReferenceParserHelpers
let(:group) { create(:group, :public) }
let(:project) { create(:project, :public, group: group) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project, :public) }
let(:merge_request) { create(:merge_request, source_project: project) } let(:merge_request) { create(:merge_request, source_project: project) }
subject(:parser) { described_class.new(Banzai::RenderContext.new(merge_request.target_project, user)) } subject(:parser) { described_class.new(Banzai::RenderContext.new(merge_request.target_project, user)) }
let(:link) { empty_html_link } let(:link) { empty_html_link }
......
...@@ -21,6 +21,11 @@ module ReferenceParserHelpers ...@@ -21,6 +21,11 @@ module ReferenceParserHelpers
end end
control = record_queries.call(control_links) control = record_queries.call(control_links)
create(:group_member, group: project.group) if project.group
create(:project_member, project: project)
create(:project_group_link, project: project)
actual = record_queries.call(actual_links) actual = record_queries.call(actual_links)
expect(actual.count).to be <= control.count expect(actual.count).to be <= control.count
......
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