Commit a2f68574 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch '198471-npm-dependencies-uploads-with-bundledependencies-false' into 'master'

Resolve "NPM dependencies: Uploads with bundleDependencies = false"

See merge request gitlab-org/gitlab!24355
parents a0311c3f bc70f918
......@@ -17,7 +17,7 @@ module Packages
private
def create_dependency(type)
return unless dependencies.key?(type)
return unless dependencies[type].is_a?(Hash)
names_and_version_patterns = dependencies[type]
existing_ids, existing_names = find_existing_ids_and_names(names_and_version_patterns)
......
---
title: Fix npm package uploads when bundleDependencies is set to false
merge_request: 24355
author:
type: fixed
......@@ -4,7 +4,7 @@ require 'spec_helper'
describe Packages::CreateDependencyService do
describe '#execute' do
let_it_be(:namespace) {create(:namespace)}
let_it_be(:version) { '1.0.1'.freeze }
let_it_be(:version) { '1.0.1' }
let_it_be(:package_name) { "@#{namespace.path}/my-app".freeze }
context 'when packages are published' do
......@@ -89,6 +89,25 @@ describe Packages::CreateDependencyService do
.and change { Packages::DependencyLink.count }.by(1)
end
end
context 'with a dependency not described with a hash' do
let(:invalid_dependencies) { dependencies.tap { |d| d['bundleDependencies'] = false } }
subject { described_class.new(package, invalid_dependencies).execute }
it 'creates dependencies and links' do
expect(Packages::Dependency)
.to receive(:ids_for_package_names_and_version_patterns)
.once
.and_call_original
expect { subject }
.to change { Packages::Dependency.count }.by(1)
.and change { Packages::DependencyLink.count }.by(1)
expect(dependency_names).to match_array(%w(express))
expect(dependency_link_types).to match_array(%w(dependencies))
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