diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-04-05 00:52:59 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-04-06 15:32:39 +0300 |
commit | 062806e47da00dde37a2a62d7a5c6ede8341582c (patch) | |
tree | bd701e49203feee98d17de8c1444339dc70c56cc /spec/serializers/pipeline_serializer_spec.rb | |
parent | 0a4b853f2ceb0ad6c7394d1056f9139e53b38688 (diff) |
Define baseline for test for pipelines serializer
Diffstat (limited to 'spec/serializers/pipeline_serializer_spec.rb')
-rw-r--r-- | spec/serializers/pipeline_serializer_spec.rb | 29 |
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 |