Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
1d79944f
Commit
1d79944f
authored
Aug 02, 2021
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check for N+1 in ProjectReferenceFilter
parent
6a1d05d4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
spec/lib/banzai/filter/references/project_reference_filter_spec.rb
...banzai/filter/references/project_reference_filter_spec.rb
+30
-0
No files found.
spec/lib/banzai/filter/references/project_reference_filter_spec.rb
View file @
1d79944f
...
@@ -97,4 +97,34 @@ RSpec.describe Banzai::Filter::References::ProjectReferenceFilter do
...
@@ -97,4 +97,34 @@ RSpec.describe Banzai::Filter::References::ProjectReferenceFilter do
expect
(
filter
.
send
(
:projects
)).
to
eq
([
project
.
full_path
])
expect
(
filter
.
send
(
:projects
)).
to
eq
([
project
.
full_path
])
end
end
end
end
context
'checking N+1'
do
let_it_be
(
:normal_project
)
{
create
(
:project
,
:public
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:group_project
)
{
create
(
:project
,
group:
group
)
}
let_it_be
(
:nested_group
)
{
create
(
:group
,
:nested
)
}
let_it_be
(
:nested_project
)
{
create
(
:project
,
group:
nested_group
)
}
let_it_be
(
:normal_project_reference
)
{
get_reference
(
normal_project
)
}
let_it_be
(
:group_project_reference
)
{
get_reference
(
group_project
)
}
let_it_be
(
:nested_project_reference
)
{
get_reference
(
nested_project
)
}
it
'does not have N+1 per multiple project references'
,
:use_sql_query_cache
do
markdown
=
"
#{
normal_project_reference
}
"
# warm up first
reference_filter
(
markdown
)
max_count
=
ActiveRecord
::
QueryRecorder
.
new
(
skip_cached:
false
)
do
reference_filter
(
markdown
)
end
.
count
expect
(
max_count
).
to
eq
1
markdown
=
"
#{
normal_project_reference
}
#{
invalidate_reference
(
normal_project_reference
)
}
#{
group_project_reference
}
#{
nested_project_reference
}
"
expect
do
reference_filter
(
markdown
)
end
.
not_to
exceed_all_query_limit
(
max_count
)
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment