Commit 7265b930 authored by Stan Hu's avatar Stan Hu

Merge branch '13175-400-bad-request-when-deploying-a-maven-package' into 'master'

Resolve "400 Bad request when deploying a maven package"

See merge request gitlab-org/gitlab-ee!14922
parents 1d788ece 987c562a
......@@ -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