Commit e6eecff1 authored by Aditya Tiwari's avatar Aditya Tiwari Committed by David Fernandez

Allow hidden pacakge files to be downloaded

Modify installable status.
Enable gitlab api to return the hidden package files.

Changelog: changed
parent 946e0078
......@@ -7,7 +7,7 @@ class Packages::Package < ApplicationRecord
include Gitlab::Utils::StrongMemoize
DISPLAYABLE_STATUSES = [:default, :error].freeze
INSTALLABLE_STATUSES = [:default].freeze
INSTALLABLE_STATUSES = [:default, :hidden].freeze
enum package_type: {
maven: 1,
......
......@@ -59,7 +59,7 @@ RSpec.describe Packages::Go::PackageFinder do
let(:version_name) { version.name }
before do
package.update_column(:status, 1)
package.update_column(:status, :error)
end
it { is_expected.to eq(nil) }
......
......@@ -39,7 +39,7 @@ RSpec.describe ::Packages::Maven::PackageFinder do
let(:param_path) { package.maven_metadatum.path }
before do
package.update_column(:status, 1)
package.update_column(:status, :error)
end
it { expect { subject }.to raise_error(ActiveRecord::RecordNotFound) }
......
......@@ -52,7 +52,7 @@ RSpec.describe ::Packages::Npm::PackageFinder do
context 'with an uninstallable package' do
before do
package.update_column(:status, 1)
package.update_column(:status, :error)
end
it { is_expected.to be_empty }
......
......@@ -36,7 +36,7 @@ RSpec.describe Packages::Nuget::PackageFinder do
context 'with an uninstallable package' do
before do
package1.update_column(:status, 1)
package1.update_column(:status, :error)
end
it { is_expected.to contain_exactly(package2) }
......
......@@ -839,6 +839,7 @@ RSpec.describe Packages::Package, type: :model do
end
context 'status scopes' do
let_it_be(:default_package) { create(:maven_package, :default) }
let_it_be(:hidden_package) { create(:maven_package, :hidden) }
let_it_be(:processing_package) { create(:maven_package, :processing) }
let_it_be(:error_package) { create(:maven_package, :error) }
......@@ -856,11 +857,15 @@ RSpec.describe Packages::Package, type: :model do
describe '.installable' do
subject { described_class.installable }
it 'does not include non-displayable packages', :aggregate_failures do
it 'does not include non-installable packages', :aggregate_failures do
is_expected.not_to include(error_package)
is_expected.not_to include(hidden_package)
is_expected.not_to include(processing_package)
end
it 'includes installable packages', :aggregate_failures do
is_expected.to include(default_package)
is_expected.to include(hidden_package)
end
end
describe '.with_status' do
......
......@@ -574,6 +574,27 @@ RSpec.describe API::GenericPackages do
end
end
context 'with package status' do
where(:package_status, :expected_status) do
:default | :success
:hidden | :success
:error | :not_found
end
with_them do
before do
project.add_developer(user)
package.update!(status: package_status)
end
it "responds with #{params[:expected_status]}" do
download_file(personal_access_token_header)
expect(response).to have_gitlab_http_status(expected_status)
end
end
end
context 'event tracking' do
let(:snowplow_gitlab_standard_context) { { project: project, namespace: project.namespace, user: user } }
......
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