Commit 987c562a authored by Steve Abrams's avatar Steve Abrams Committed by Stan Hu

Remove package_already_taken validation from Maven

Validating that two projects could not have the same package
name for Maven projects was causing problems when users
used one project to create packages for other projects
using CI. The validation is being removed from Maven.
parent 1d788ece
......@@ -13,7 +13,7 @@ class Packages::Package < ApplicationRecord
format: { with: Gitlab::Regex.package_name_regex }
validate :valid_npm_package_name, if: :npm?
validate :package_already_taken
validate :package_already_taken, if: :npm?
enum package_type: { maven: 1, npm: 2 }
......
---
title: Change package validation scope to fix Maven package naming functionality
merge_request: 14922
author:
type: fixed
......@@ -15,6 +15,28 @@ RSpec.describe Packages::Package, type: :model do
it { is_expected.to allow_value("my.app-11.07.2018").for(:name) }
it { is_expected.not_to allow_value("my(dom$$$ain)com.my-app").for(:name) }
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, name: package.name)
expect(new_package).not_to be_valid
end
end
context 'maven package' do
let!(:package) { create(:maven_package) }
it 'will allow a package of the same name' do
new_package = build(:maven_package, name: package.name)
expect(new_package).to be_valid
end
end
end
end
describe '.by_name_and_file_name' do
......
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