Commit 09236cc9 authored by Tiger Watson's avatar Tiger Watson

Merge branch '211924-add-has_version-check-to-package-finders' into 'master'

Add has_version check to project and group package finders

Closes #211924

See merge request gitlab-org/gitlab!27780
parents 7ba55f15 a076f26c
...@@ -22,6 +22,7 @@ module Packages ...@@ -22,6 +22,7 @@ module Packages
packages = ::Packages::Package packages = ::Packages::Package
.for_projects(group_projects_visible_to_current_user) .for_projects(group_projects_visible_to_current_user)
.processed .processed
.has_version
.sort_by_attribute("#{params[:order_by]}_#{params[:sort]}") .sort_by_attribute("#{params[:order_by]}_#{params[:sort]}")
return packages unless package_type return packages unless package_type
......
...@@ -13,7 +13,7 @@ module Packages ...@@ -13,7 +13,7 @@ module Packages
end end
def execute def execute
packages = project.packages.processed packages = project.packages.processed.has_version
packages = filter_by_package_type(packages) packages = filter_by_package_type(packages)
packages = filter_by_package_name(packages) packages = filter_by_package_name(packages)
packages = order_packages(packages) packages = order_packages(packages)
......
...@@ -52,6 +52,12 @@ describe Packages::GroupPackagesFinder do ...@@ -52,6 +52,12 @@ describe Packages::GroupPackagesFinder do
it { is_expected.to match_array([package1, package2]) } it { is_expected.to match_array([package1, package2]) }
end end
context 'does not include packages without version number' do
let!(:package_without_version) { create(:maven_package, project: project, version: nil) }
it { is_expected.not_to include(package_without_version) }
end
end end
context 'group has package of all types' do context 'group has package of all types' do
......
...@@ -80,5 +80,11 @@ describe ::Packages::PackagesFinder do ...@@ -80,5 +80,11 @@ describe ::Packages::PackagesFinder do
it { is_expected.to match_array([conan_package, maven_package]) } it { is_expected.to match_array([conan_package, maven_package]) }
end end
context 'does not include packages without version number' do
let_it_be(:package_without_version) { create(:maven_package, project: project, version: nil) }
it { is_expected.not_to include(package_without_version) }
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment