summaryrefslogtreecommitdiff
path: root/spec/serializers
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-04-13 15:08:52 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-04-13 15:08:52 +0200
commita8231ea1befd803fb5892ea3e6679219f5d7d8e5 (patch)
treea5bfe0cec13735bb36ba010c7dbacfaf13ba135f /spec/serializers
parent57f8f2d7ff851fc4f5d1c81a28a023855f1985b7 (diff)
parent37ab389139a21a8ab10ddbbddec1b61f720b27ab (diff)
downloadgitlab-ce-a8231ea1befd803fb5892ea3e6679219f5d7d8e5.tar.gz
Merge branch 'master' into feature/gb/manual-actions-protected-branches-permissions
* master: (641 commits) Revert "Fix registry for projects with uppercases in path" Fix registry for projects with uppercases in path Move event icons into events_helper Reset New branch button when issue state changes Add link to environments on kubernetes.md Indent system notes on desktop screens Improve webpack-dev-server compatibility with non-localhost setups. Add changelog entry Fix recent searches icon alignment in Safari Use preload to avoid Rails using JOIN Fix NUMBER_OF_TRUNCATED_DIFF_LINES re-definition error Prepare for zero downtime migrations Fix filtered search input width for IE Fix the `gitlab:gitlab_shell:check` task Fixed random failures with Poll spec Include CONTRIBUTING.md file when importing .gitlab-ci.yml templates Let uses hide verbose output by default Separate examples for each other Collapse similar sibling scenarios Use empty_project for resources that are independent of the repo ... Conflicts: app/views/projects/ci/builds/_build.html.haml
Diffstat (limited to 'spec/serializers')
-rw-r--r--spec/serializers/pipeline_serializer_spec.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/serializers/pipeline_serializer_spec.rb b/spec/serializers/pipeline_serializer_spec.rb
index 8642b803844..f6249ab4664 100644
--- a/spec/serializers/pipeline_serializer_spec.rb
+++ b/spec/serializers/pipeline_serializer_spec.rb
@@ -93,6 +93,44 @@ describe PipelineSerializer do
end
end
end
+
+ context 'number of queries' do
+ let(:resource) { Ci::Pipeline.all }
+ let(:project) { create(:empty_project) }
+
+ before do
+ Ci::Pipeline::AVAILABLE_STATUSES.each do |status|
+ create_pipeline(status)
+ end
+
+ RequestStore.begin!
+ end
+
+ after do
+ RequestStore.end!
+ RequestStore.clear!
+ end
+
+ it "verifies number of queries" do
+ recorded = ActiveRecord::QueryRecorder.new { subject }
+ expect(recorded.count).to be_within(1).of(50)
+ expect(recorded.cached_count).to eq(0)
+ end
+
+ def create_pipeline(status)
+ create(:ci_empty_pipeline, project: project, 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