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
09118796
Commit
09118796
authored
Jan 14, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add N+1 query spec for Jobs API
parent
c9840842
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
2 deletions
+13
-2
spec/requests/api/jobs_spec.rb
spec/requests/api/jobs_spec.rb
+13
-2
No files found.
spec/requests/api/jobs_spec.rb
View file @
09118796
...
...
@@ -25,8 +25,10 @@ describe API::Jobs do
describe
'GET /projects/:id/jobs'
do
let
(
:query
)
{
Hash
.
new
}
before
do
get
api
(
"/projects/
#{
project
.
id
}
/jobs"
,
api_user
),
query
before
do
|
example
|
unless
example
.
metadata
[
:skip_before_request
]
get
api
(
"/projects/
#{
project
.
id
}
/jobs"
,
api_user
),
query
end
end
context
'authorized user'
do
...
...
@@ -51,6 +53,12 @@ describe API::Jobs do
expect
(
json_job
[
'pipeline'
][
'status'
]).
to
eq
job
.
pipeline
.
status
end
it
'avoids N+1 queries'
,
skip_before_request:
true
do
control_count
=
ActiveRecord
::
QueryRecorder
.
new
{
go
}.
count
create_list
(
:ci_build
,
5
,
pipeline:
pipeline
)
expect
{
go
}.
not_to
exceed_query_limit
(
control_count
)
end
context
'filter project with one scope element'
do
let
(
:query
)
{
{
'scope'
=>
'pending'
}
}
...
...
@@ -83,6 +91,9 @@ describe API::Jobs do
expect
(
response
).
to
have_gitlab_http_status
(
401
)
end
end
def
go
get
api
(
"/projects/
#{
project
.
id
}
/jobs"
,
api_user
),
query
end
end
describe
'GET /projects/:id/pipelines/:pipeline_id/jobs'
do
...
...
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