summaryrefslogtreecommitdiff
path: root/spec/serializers/pipeline_serializer_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-06-16 18:25:58 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-06-16 18:25:58 +0000
commita5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch)
treefb69158581673816a8cd895f9d352dcb3c678b1e /spec/serializers/pipeline_serializer_spec.rb
parentd16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff)
downloadgitlab-ce-14.0.0-rc42.tar.gz
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'spec/serializers/pipeline_serializer_spec.rb')
-rw-r--r--spec/serializers/pipeline_serializer_spec.rb19
1 files changed, 9 insertions, 10 deletions
diff --git a/spec/serializers/pipeline_serializer_spec.rb b/spec/serializers/pipeline_serializer_spec.rb
index 1111290cade..bcad9eb6e23 100644
--- a/spec/serializers/pipeline_serializer_spec.rb
+++ b/spec/serializers/pipeline_serializer_spec.rb
@@ -212,18 +212,17 @@ RSpec.describe PipelineSerializer do
context 'with build environments' do
let(:ref) { 'feature' }
- it 'verifies number of queries', :request_store do
- stub_licensed_features(protected_environments: true)
+ let_it_be(:production) { create(:environment, :production, project: project) }
+ let_it_be(:staging) { create(:environment, :staging, project: project) }
- env = create(:environment, project: project)
- create(:ci_build, :scheduled, project: project, environment: env.name)
- create(:ci_build, :scheduled, project: project, environment: env.name)
- create(:ci_build, :scheduled, project: project, environment: env.name)
+ it 'executes one query to fetch all related environments', :request_store do
+ pipeline = create(:ci_pipeline, project: project)
+ create(:ci_build, :manual, pipeline: pipeline, environment: production.name)
+ create(:ci_build, :manual, pipeline: pipeline, environment: staging.name)
+ create(:ci_build, :scheduled, pipeline: pipeline, environment: production.name)
+ create(:ci_build, :scheduled, pipeline: pipeline, environment: staging.name)
- recorded = ActiveRecord::QueryRecorder.new { subject }
- expected_queries = Gitlab.ee? ? 56 : 52
- expect(recorded.count).to be_within(1).of(expected_queries)
- expect(recorded.cached_count).to eq(0)
+ expect { subject }.not_to exceed_query_limit(1).for_query /SELECT "environments".*/
end
end