diff options
Diffstat (limited to 'spec/serializers')
-rw-r--r-- | spec/serializers/analytics_build_entity_spec.rb | 8 | ||||
-rw-r--r-- | spec/serializers/analytics_issue_entity_spec.rb | 8 | ||||
-rw-r--r-- | spec/serializers/environment_serializer_spec.rb | 36 | ||||
-rw-r--r-- | spec/serializers/group_child_entity_spec.rb | 4 | ||||
-rw-r--r-- | spec/serializers/pipeline_serializer_spec.rb | 2 |
5 files changed, 57 insertions, 1 deletions
diff --git a/spec/serializers/analytics_build_entity_spec.rb b/spec/serializers/analytics_build_entity_spec.rb index 09804681f5d..b5678d91248 100644 --- a/spec/serializers/analytics_build_entity_spec.rb +++ b/spec/serializers/analytics_build_entity_spec.rb @@ -27,6 +27,14 @@ RSpec.describe AnalyticsBuildEntity do expect(subject).to include(:author) end + it 'contains the project path' do + expect(subject).to include(:project_path) + end + + it 'contains the namespace full path' do + expect(subject).to include(:namespace_full_path) + end + it 'does not contain sensitive information' do expect(subject).not_to include(/token/) expect(subject).not_to include(/variables/) diff --git a/spec/serializers/analytics_issue_entity_spec.rb b/spec/serializers/analytics_issue_entity_spec.rb index 447c5e7d02a..bc5cab638cd 100644 --- a/spec/serializers/analytics_issue_entity_spec.rb +++ b/spec/serializers/analytics_issue_entity_spec.rb @@ -32,6 +32,14 @@ RSpec.describe AnalyticsIssueEntity do expect(subject).to include(:author) end + it 'contains the project path' do + expect(subject).to include(:project_path) + end + + it 'contains the namespace full path' do + expect(subject).to include(:namespace_full_path) + end + it 'does not contain sensitive information' do expect(subject).not_to include(/token/) expect(subject).not_to include(/variables/) diff --git a/spec/serializers/environment_serializer_spec.rb b/spec/serializers/environment_serializer_spec.rb index 985e18f27a0..80b6f00d8c9 100644 --- a/spec/serializers/environment_serializer_spec.rb +++ b/spec/serializers/environment_serializer_spec.rb @@ -185,6 +185,42 @@ RSpec.describe EnvironmentSerializer do end end + context 'batching loading' do + let(:resource) { Environment.all } + + before do + create(:environment, name: 'staging/review-1') + create_environment_with_associations(project) + end + + it 'uses the custom preloader service' do + expect_next_instance_of(Preloaders::Environments::DeploymentPreloader) do |preloader| + expect(preloader).to receive(:execute_with_union).with(:last_deployment, hash_including(:deployable)).and_call_original + end + + expect_next_instance_of(Preloaders::Environments::DeploymentPreloader) do |preloader| + expect(preloader).to receive(:execute_with_union).with(:upcoming_deployment, hash_including(:deployable)).and_call_original + end + + json + end + + # Including for test coverage pipeline failure, remove along with feature flag. + context 'when custom preload feature is disabled' do + before do + Feature.disable(:custom_preloader_for_deployments) + end + + it 'avoids N+1 database queries' do + control_count = ActiveRecord::QueryRecorder.new { json }.count + + create_environment_with_associations(project) + + expect { json }.not_to exceed_query_limit(control_count) + end + end + end + def create_environment_with_associations(project) create(:environment, project: project).tap do |environment| create(:deployment, :success, environment: environment, project: project) diff --git a/spec/serializers/group_child_entity_spec.rb b/spec/serializers/group_child_entity_spec.rb index e4844c25067..59340181075 100644 --- a/spec/serializers/group_child_entity_spec.rb +++ b/spec/serializers/group_child_entity_spec.rb @@ -62,6 +62,10 @@ RSpec.describe GroupChildEntity do expect(json[:edit_path]).to eq(edit_project_path(object)) end + it 'includes the last activity at' do + expect(json[:last_activity_at]).to be_present + end + it_behaves_like 'group child json' end diff --git a/spec/serializers/pipeline_serializer_spec.rb b/spec/serializers/pipeline_serializer_spec.rb index 587d167520f..f5398013a70 100644 --- a/spec/serializers/pipeline_serializer_spec.rb +++ b/spec/serializers/pipeline_serializer_spec.rb @@ -202,7 +202,7 @@ RSpec.describe PipelineSerializer do # Existing numbers are high and require performance optimization # Ongoing issue: # https://gitlab.com/gitlab-org/gitlab/-/issues/225156 - expected_queries = Gitlab.ee? ? 74 : 70 + expected_queries = Gitlab.ee? ? 78 : 74 expect(recorded.count).to be_within(2).of(expected_queries) expect(recorded.cached_count).to eq(0) |