summaryrefslogtreecommitdiff
path: root/spec/models/packages/package_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-02-23 09:14:52 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-02-23 09:14:52 +0000
commit347bf09d6ecf4871da234c06ca8ee541e27b5105 (patch)
tree2ad6943e0c681c22acc8850d1debc6a983b0e006 /spec/models/packages/package_spec.rb
parent0a51be0866d33273070f535257626a9eb2e10700 (diff)
downloadgitlab-ce-13.10.0-rc20210223090520.tar.gz
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc20210223090520
Diffstat (limited to 'spec/models/packages/package_spec.rb')
-rw-r--r--spec/models/packages/package_spec.rb26
1 files changed, 14 insertions, 12 deletions
diff --git a/spec/models/packages/package_spec.rb b/spec/models/packages/package_spec.rb
index 6c55d37b95f..fc0bd34a331 100644
--- a/spec/models/packages/package_spec.rb
+++ b/spec/models/packages/package_spec.rb
@@ -162,6 +162,18 @@ RSpec.describe Packages::Package, type: :model do
it { is_expected.not_to allow_value('../../../my_package').for(:name) }
it { is_expected.not_to allow_value('%2e%2e%2fmy_package').for(:name) }
end
+
+ context 'npm package' do
+ subject { build_stubbed(:npm_package) }
+
+ it { is_expected.to allow_value("@group-1/package").for(:name) }
+ it { is_expected.to allow_value("@any-scope/package").for(:name) }
+ it { is_expected.to allow_value("unscoped-package").for(:name) }
+ it { is_expected.not_to allow_value("@inv@lid-scope/package").for(:name) }
+ it { is_expected.not_to allow_value("@scope/../../package").for(:name) }
+ it { is_expected.not_to allow_value("@scope%2e%2e%fpackage").for(:name) }
+ it { is_expected.not_to allow_value("@scope/sub/package").for(:name) }
+ end
end
describe '#version' do
@@ -342,16 +354,6 @@ RSpec.describe Packages::Package, type: :model do
end
describe '#package_already_taken' do
- context 'npm package' do
- let!(:package) { create(:npm_package) }
-
- it 'will not allow a package of the same name' do
- new_package = build(:npm_package, project: create(:project), name: package.name)
-
- expect(new_package).not_to be_valid
- end
- end
-
context 'maven package' do
let!(:package) { create(:maven_package) }
@@ -511,7 +513,7 @@ RSpec.describe Packages::Package, type: :model do
describe '.without_nuget_temporary_name' do
let!(:package1) { create(:nuget_package) }
- let!(:package2) { create(:nuget_package, name: Packages::Nuget::CreatePackageService::TEMPORARY_PACKAGE_NAME) }
+ let!(:package2) { create(:nuget_package, name: Packages::Nuget::TEMPORARY_PACKAGE_NAME) }
subject { described_class.without_nuget_temporary_name }
@@ -530,7 +532,7 @@ RSpec.describe Packages::Package, type: :model do
it { is_expected.to match_array([package1, package2, package3]) }
context 'with temporary packages' do
- let!(:package1) { create(:nuget_package, name: Packages::Nuget::CreatePackageService::TEMPORARY_PACKAGE_NAME) }
+ let!(:package1) { create(:nuget_package, name: Packages::Nuget::TEMPORARY_PACKAGE_NAME) }
it { is_expected.to match_array([package2, package3]) }
end