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
Show 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
FactoryGirl
.
define
do
factory
:ci_trigger_without_token
,
class:
Ci
::
Trigger
do
factory
:ci_trigger_without_token
,
class:
Ci
::
Trigger
do
factory
:ci_trigger
do
factory
:ci_trigger
do
token
'token'
sequence
(
:token
)
{
|
n
|
"token
#{
n
}
"
}
end
end
end
end
end
end
spec/serializers/pipeline_serializer_spec.rb
View file @
062806e4
...
@@ -93,6 +93,35 @@ describe PipelineSerializer do
...
@@ -93,6 +93,35 @@ describe PipelineSerializer do
end
end
end
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
end
describe
'#represent_status'
do
describe
'#represent_status'
do
...
...
spec/support/query_recorder.rb
View file @
062806e4
module
ActiveRecord
module
ActiveRecord
class
QueryRecorder
class
QueryRecorder
attr_reader
:log
attr_reader
:log
,
:cached
def
initialize
(
&
block
)
def
initialize
(
&
block
)
@log
=
[]
@log
=
[]
@cached
=
[]
ActiveSupport
::
Notifications
.
subscribed
(
method
(
:callback
),
'sql.active_record'
,
&
block
)
ActiveSupport
::
Notifications
.
subscribed
(
method
(
:callback
),
'sql.active_record'
,
&
block
)
end
end
def
callback
(
name
,
start
,
finish
,
message_id
,
values
)
def
callback
(
name
,
start
,
finish
,
message_id
,
values
)
return
if
%w(CACHE SCHEMA)
.
include?
(
values
[
:name
])
if
values
[
:name
]
&
.
include?
(
"CACHE"
)
@cached
<<
values
[
:sql
]
elsif
!
values
[
:name
]
&
.
include?
(
"SCHEMA"
)
@log
<<
values
[
:sql
]
@log
<<
values
[
:sql
]
end
end
end
def
count
def
count
@log
.
count
@log
.
count
end
end
def
cached_count
@cached
.
count
end
def
log_message
def
log_message
@log
.
join
(
"
\n\n
"
)
@log
.
join
(
"
\n\n
"
)
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