diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
commit | 05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch) | |
tree | 11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /spec/presenters/packages/nuget/packages_metadata_presenter_spec.rb | |
parent | ec73467c23693d0db63a797d10194da9e72a74af (diff) |
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'spec/presenters/packages/nuget/packages_metadata_presenter_spec.rb')
-rw-r--r-- | spec/presenters/packages/nuget/packages_metadata_presenter_spec.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/spec/presenters/packages/nuget/packages_metadata_presenter_spec.rb b/spec/presenters/packages/nuget/packages_metadata_presenter_spec.rb index 39682a3311c..87a87cd8d70 100644 --- a/spec/presenters/packages/nuget/packages_metadata_presenter_spec.rb +++ b/spec/presenters/packages/nuget/packages_metadata_presenter_spec.rb @@ -2,12 +2,13 @@ require 'spec_helper' -RSpec.describe Packages::Nuget::PackagesMetadataPresenter do +RSpec.describe Packages::Nuget::PackagesMetadataPresenter, feature_category: :package_registry do include_context 'with expected presenters dependency groups' let_it_be(:project) { create(:project) } let_it_be(:packages) { create_list(:nuget_package, 5, :with_metadatum, name: 'Dummy.Package', project: project) } - let_it_be(:presenter) { described_class.new(packages) } + + let(:presenter) { described_class.new(project.packages) } describe '#count' do subject { presenter.count } @@ -28,6 +29,14 @@ RSpec.describe Packages::Nuget::PackagesMetadataPresenter do end end + it 'avoids N+1 database queries' do + control = ActiveRecord::QueryRecorder.new { described_class.new(project.packages).items } + + create(:nuget_package, :with_metadatum, name: 'Dummy.Package', project: project) + + expect { described_class.new(project.packages).items }.not_to exceed_query_limit(control) + end + it 'returns an array' do items = subject |