summaryrefslogtreecommitdiff
path: root/spec/serializers
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2017-04-04 23:52:59 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2017-04-06 14:32:39 +0200
commit062806e47da00dde37a2a62d7a5c6ede8341582c (patch)
treebd701e49203feee98d17de8c1444339dc70c56cc /spec/serializers
parent0a4b853f2ceb0ad6c7394d1056f9139e53b38688 (diff)
downloadgitlab-ce-062806e47da00dde37a2a62d7a5c6ede8341582c.tar.gz
Define baseline for test for pipelines serializer
Diffstat (limited to 'spec/serializers')
-rw-r--r--spec/serializers/pipeline_serializer_spec.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/serializers/pipeline_serializer_spec.rb b/spec/serializers/pipeline_serializer_spec.rb
index 8642b803844..657d10aae99 100644
--- a/spec/serializers/pipeline_serializer_spec.rb
+++ b/spec/serializers/pipeline_serializer_spec.rb
@@ -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