diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-21 06:10:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-21 06:10:24 +0300 |
commit | fc5e0c4d0d11592d6cbc420158dd0c470eb236a5 (patch) | |
tree | 8f57371109c2f3b99338a04cd95ef75a735c6427 /spec/serializers/pipeline_serializer_spec.rb | |
parent | d324f74adcc3299de60203ba4d5301d56114b1a8 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/serializers/pipeline_serializer_spec.rb')
-rw-r--r-- | spec/serializers/pipeline_serializer_spec.rb | 19 |
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 |