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
013e4d37
Commit
013e4d37
authored
Oct 05, 2020
by
Reuben Pereira
Committed by
Igor Drozdov
Oct 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add N+1 spec for the namespaces list API
parent
85ece798
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
ee/spec/requests/api/namespaces_spec.rb
ee/spec/requests/api/namespaces_spec.rb
+18
-0
No files found.
ee/spec/requests/api/namespaces_spec.rb
View file @
013e4d37
...
...
@@ -123,6 +123,24 @@ RSpec.describe API::Namespaces do
create
(
:gitlab_subscription
,
namespace:
group1
,
max_seats_used:
1
)
end
it
"avoids additional N+1 database queries"
do
control
=
ActiveRecord
::
QueryRecorder
.
new
(
skip_cached:
false
)
{
get
api
(
"/namespaces"
,
user
)
}
create
(
:gitlab_subscription
,
namespace:
group2
,
max_seats_used:
2
)
group2
.
add_guest
(
user
)
group3
=
create
(
:group
)
create
(
:gitlab_subscription
,
namespace:
group3
,
max_seats_used:
3
)
group3
.
add_guest
(
user
)
# We seem to have some N+1 queries.
# The saml_provider association adds one for each group (saml_provider is
# an association on group, not namespace).
# The route adds one for each namespace.
# And more...
expect
{
get
api
(
"/namespaces"
,
user
)
}.
not_to
exceed_all_query_limit
(
control
).
with_threshold
(
10
)
end
it
'includes max_seats_used'
do
get
api
(
"/namespaces"
,
user
)
...
...
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