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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
062806e4
Commit
062806e4
authored
Apr 04, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Define baseline for test for pipelines serializer
parent
0a4b853f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
4 deletions
+41
-4
spec/factories/ci/triggers.rb
spec/factories/ci/triggers.rb
+1
-1
spec/serializers/pipeline_serializer_spec.rb
spec/serializers/pipeline_serializer_spec.rb
+29
-0
spec/support/query_recorder.rb
spec/support/query_recorder.rb
+11
-3
No files found.
spec/factories/ci/triggers.rb
View file @
062806e4
FactoryGirl
.
define
do
factory
:ci_trigger_without_token
,
class:
Ci
::
Trigger
do
factory
:ci_trigger
do
token
'token'
sequence
(
:token
)
{
|
n
|
"token
#{
n
}
"
}
end
end
end
spec/serializers/pipeline_serializer_spec.rb
View file @
062806e4
...
...
@@ -93,6 +93,35 @@ describe PipelineSerializer do
end
end
end
context
'number of queries'
do
let
(
:resource
)
{
Ci
::
Pipeline
.
all
}
before
do
Ci
::
Pipeline
::
AVAILABLE_STATUSES
.
each
do
|
status
|
create_pipeline
(
status
)
end
end
it
"verifies number of queries"
do
recorded
=
ActiveRecord
::
QueryRecorder
.
new
{
subject
}
expect
(
recorded
.
count
).
to
be_within
(
320
).
of
(
10
)
end
def
create_pipeline
(
status
)
create
(
:ci_empty_pipeline
,
status:
status
).
tap
do
|
pipeline
|
Ci
::
Build
::
AVAILABLE_STATUSES
.
each
do
|
status
|
create_build
(
pipeline
,
status
,
status
)
end
end
end
def
create_build
(
pipeline
,
stage
,
status
)
create
(
:ci_build
,
:tags
,
:triggered
,
:artifacts
,
pipeline:
pipeline
,
stage:
stage
,
name:
stage
,
status:
status
)
end
end
end
describe
'#represent_status'
do
...
...
spec/support/query_recorder.rb
View file @
062806e4
module
ActiveRecord
class
QueryRecorder
attr_reader
:log
attr_reader
:log
,
:cached
def
initialize
(
&
block
)
@log
=
[]
@cached
=
[]
ActiveSupport
::
Notifications
.
subscribed
(
method
(
:callback
),
'sql.active_record'
,
&
block
)
end
def
callback
(
name
,
start
,
finish
,
message_id
,
values
)
return
if
%w(CACHE SCHEMA)
.
include?
(
values
[
:name
])
@log
<<
values
[
:sql
]
if
values
[
:name
]
&
.
include?
(
"CACHE"
)
@cached
<<
values
[
:sql
]
elsif
!
values
[
:name
]
&
.
include?
(
"SCHEMA"
)
@log
<<
values
[
:sql
]
end
end
def
count
@log
.
count
end
def
cached_count
@cached
.
count
end
def
log_message
@log
.
join
(
"
\n\n
"
)
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