Commit 99d8981a authored by Stan Hu's avatar Stan Hu

Merge branch '198645-NPM-dependencies-remove-deprecated-key' into 'master'

fix: 198645 NPM dependencies, remove deprecated key

Closes #198645

See merge request gitlab-org/gitlab!23745
parents 428709d8 fc1005a4
......@@ -8,7 +8,7 @@ class Packages::DependencyLink < ApplicationRecord
validates :dependency_type,
uniqueness: { scope: %i[package_id dependency_id] }
enum dependency_type: { dependencies: 1, devDependencies: 2, bundleDependencies: 3, peerDependencies: 4, deprecated: 5 }
enum dependency_type: { dependencies: 1, devDependencies: 2, bundleDependencies: 3, peerDependencies: 4 }
scope :with_dependency_type, ->(dependency_type) { where(dependency_type: dependency_type) }
scope :includes_dependency, -> { includes(:dependency) }
......
......@@ -7,7 +7,7 @@ module Packages
attr_reader :name, :packages
NPM_VALID_DEPENDENCY_TYPES = %i[dependencies devDependencies bundleDependencies peerDependencies deprecated].freeze
NPM_VALID_DEPENDENCY_TYPES = %i[dependencies devDependencies bundleDependencies peerDependencies].freeze
def initialize(name, packages)
@name = name
......
......@@ -40,7 +40,6 @@ describe API::NpmPackages do
let!(:package_dependency_link2) { create(:packages_dependency_link, package: package, dependency_type: :devDependencies) }
let!(:package_dependency_link3) { create(:packages_dependency_link, package: package, dependency_type: :bundleDependencies) }
let!(:package_dependency_link4) { create(:packages_dependency_link, package: package, dependency_type: :peerDependencies) }
let!(:package_dependency_link5) { create(:packages_dependency_link, package: package, dependency_type: :deprecated) }
context 'a public project' do
it 'returns the package info without oauth token' do
......@@ -301,7 +300,7 @@ describe API::NpmPackages do
.to change { project.packages.count }.by(1)
.and change { Packages::PackageFile.count }.by(1)
.and change { Packages::Dependency.count}.by(4)
.and change { Packages::DependencyLink.count}.by(7)
.and change { Packages::DependencyLink.count}.by(6)
expect(response).to have_gitlab_http_status(200)
end
......@@ -317,7 +316,7 @@ describe API::NpmPackages do
.to change { project.packages.count }.by(1)
.and change { Packages::PackageFile.count }.by(1)
.and not_change { Packages::Dependency.count}
.and change { Packages::DependencyLink.count}.by(7)
.and change { Packages::DependencyLink.count}.by(6)
end
end
end
......
......@@ -42,14 +42,14 @@ describe Packages::CreateDependencyService do
it 'creates dependencies and links' do
expect(Packages::Dependency)
.to receive(:ids_for_package_names_and_version_patterns)
.exactly(5).times
.exactly(4).times
.and_call_original
expect { subject }
.to change { Packages::Dependency.count }.by(4)
.and change { Packages::DependencyLink.count }.by(7)
expect(dependency_names).to match_array(%w(d3 d3 d3 dagre-d3 dagre-d3 express express))
expect(dependency_link_types).to match_array(%w(bundleDependencies dependencies dependencies deprecated devDependencies devDependencies peerDependencies))
.and change { Packages::DependencyLink.count }.by(6)
expect(dependency_names).to match_array(%w(d3 d3 d3 dagre-d3 dagre-d3 express))
expect(dependency_link_types).to match_array(%w(bundleDependencies dependencies dependencies devDependencies devDependencies peerDependencies))
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