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
6165ed01
Commit
6165ed01
authored
Jul 28, 2021
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check for N+1 in CommitReferenceFilter
parent
1f56f09a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
spec/lib/banzai/filter/references/commit_reference_filter_spec.rb
.../banzai/filter/references/commit_reference_filter_spec.rb
+30
-0
No files found.
spec/lib/banzai/filter/references/commit_reference_filter_spec.rb
View file @
6165ed01
...
...
@@ -269,4 +269,34 @@ RSpec.describe Banzai::Filter::References::CommitReferenceFilter do
expect
(
reference_filter
(
act
,
context
).
css
(
'a'
).
first
.
text
).
to
eql
(
"
#{
project
.
full_path
}
@
#{
commit
.
short_id
}
"
)
end
end
context
'checking N+1'
do
let
(
:namespace2
)
{
create
(
:namespace
)
}
let
(
:namespace3
)
{
create
(
:namespace
)
}
let
(
:project2
)
{
create
(
:project
,
:public
,
:repository
,
namespace:
namespace2
)
}
let
(
:project3
)
{
create
(
:project
,
:public
,
:repository
,
namespace:
namespace3
)
}
let
(
:commit2
)
{
project2
.
commit
}
let
(
:commit3
)
{
project3
.
commit
}
let
(
:commit_reference
)
{
commit
.
to_reference
}
let
(
:commit2_reference
)
{
commit2
.
to_reference
(
full:
true
)
}
let
(
:commit3_reference
)
{
commit3
.
to_reference
(
full:
true
)
}
it
'does not have N+1 per multiple references per project'
,
:use_sql_query_cache
do
markdown
=
"
#{
commit_reference
}
"
max_count
=
ActiveRecord
::
QueryRecorder
.
new
(
skip_cached:
false
)
do
reference_filter
(
markdown
)
end
.
count
markdown
=
"
#{
commit_reference
}
8b95f2f1 8b95f2f2 8b95f2f3
#{
commit2_reference
}
#{
commit3_reference
}
"
# Commits are not DB entries, they are on the project itself.
# So adding commits from two more projects to the markdown should
# only increase by 1 query
max_count
+=
1
expect
do
reference_filter
(
markdown
)
end
.
not_to
exceed_all_query_limit
(
max_count
)
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