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
7e084984
Commit
7e084984
authored
Jan 13, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add n plus one spec for v3 builds api
parent
74f2f9b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
2 deletions
+14
-2
spec/requests/api/v3/builds_spec.rb
spec/requests/api/v3/builds_spec.rb
+14
-2
No files found.
spec/requests/api/v3/builds_spec.rb
View file @
7e084984
...
...
@@ -13,10 +13,12 @@ describe API::V3::Builds do
describe
'GET /projects/:id/builds '
do
let
(
:query
)
{
''
}
before
do
before
do
|
example
|
create
(
:ci_build
,
:skipped
,
pipeline:
pipeline
)
get
v3_api
(
"/projects/
#{
project
.
id
}
/builds?
#{
query
}
"
,
api_user
)
unless
example
.
metadata
[
:skip_before_request
]
get
v3_api
(
"/projects/
#{
project
.
id
}
/builds?
#{
query
}
"
,
api_user
)
end
end
context
'authorized user'
do
...
...
@@ -40,6 +42,12 @@ describe API::V3::Builds do
expect
(
json_build
[
'pipeline'
][
'status'
]).
to
eq
build
.
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'
}
...
...
@@ -84,6 +92,10 @@ describe API::V3::Builds do
expect
(
response
).
to
have_gitlab_http_status
(
401
)
end
end
def
go
get
v3_api
(
"/projects/
#{
project
.
id
}
/builds?
#{
query
}
"
,
api_user
)
end
end
describe
'GET /projects/:id/repository/commits/:sha/builds'
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