Commit 6f132d48 authored by James Lopez's avatar James Lopez

Merge branch...

Merge branch '208678-packages-project-and-group-api-will-return-processing-nuget-packages' into 'master'

Prevent NuGet processing packages being returned by the API

See merge request gitlab-org/gitlab!26270
parents 67502abd a7c45e47
---
title: Fixed bug where processing NuGet packages are returned from the Packages API
merge_request: 26270
author:
type: fixed
...@@ -21,6 +21,7 @@ module Packages ...@@ -21,6 +21,7 @@ module Packages
def packages_for_group_projects def packages_for_group_projects
packages = ::Packages::Package packages = ::Packages::Package
.for_projects(group_projects_visible_to_current_user) .for_projects(group_projects_visible_to_current_user)
.processed
.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
......
...@@ -7,7 +7,10 @@ module Packages ...@@ -7,7 +7,10 @@ module Packages
end end
def execute def execute
@project.packages.find(@package_id) @project
.packages
.processed
.find(@package_id)
end end
end end
end end
...@@ -13,7 +13,7 @@ module Packages ...@@ -13,7 +13,7 @@ module Packages
end end
def execute def execute
packages = project.packages packages = project.packages.processed
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)
......
...@@ -46,6 +46,12 @@ describe Packages::GroupPackagesFinder do ...@@ -46,6 +46,12 @@ describe Packages::GroupPackagesFinder do
it { is_expected.to match_array([package1, package2]) } it { is_expected.to match_array([package1, package2]) }
end end
end end
context 'when there are processing packages' do
let!(:package4) { create(:nuget_package, project: project, name: Packages::Nuget::CreatePackageService::TEMPORARY_PACKAGE_NAME) }
it { is_expected.to match_array([package1, package2]) }
end
end end
context 'group has package of all types' do context 'group has package of all types' do
......
# frozen_string_literal: true
require 'spec_helper'
describe ::Packages::PackageFinder do
let_it_be(:project) { create(:project) }
let_it_be(:maven_package) { create(:maven_package, project: project) }
describe '#execute' do
let(:package_id) { maven_package.id }
subject { described_class.new(project, package_id).execute }
it { is_expected.to eq(maven_package) }
context 'processing packages' do
let_it_be(:nuget_package) { create(:nuget_package, project: project, name: Packages::Nuget::CreatePackageService::TEMPORARY_PACKAGE_NAME) }
let(:package_id) { nuget_package.id }
it 'are not returned' do
expect { subject }.to raise_exception(ActiveRecord::RecordNotFound)
end
end
end
end
...@@ -74,5 +74,11 @@ describe ::Packages::PackagesFinder do ...@@ -74,5 +74,11 @@ describe ::Packages::PackagesFinder do
context 'with nil params' do context 'with nil params' do
it { is_expected.to match_array([conan_package, maven_package]) } it { is_expected.to match_array([conan_package, maven_package]) }
end end
context 'with processing packages' do
let_it_be(:nuget_package) { create(:nuget_package, project: project, name: Packages::Nuget::CreatePackageService::TEMPORARY_PACKAGE_NAME) }
it { is_expected.to match_array([conan_package, maven_package]) }
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