Commit f203f891 authored by Andreas Brandl's avatar Andreas Brandl

Add validation for project_feature

Relates to: https://gitlab.com/gitlab-org/gitlab/issues/34367
parent 4505da2c
......@@ -357,6 +357,8 @@ class Project < ApplicationRecord
project_path: true,
length: { maximum: 255 }
validates :project_feature, presence: true
validates :namespace, presence: true
validates :name, uniqueness: { scope: :namespace_id }
validates :import_url, public_url: { schemes: ->(project) { project.persisted? ? VALID_MIRROR_PROTOCOLS : VALID_IMPORT_PROTOCOLS },
......
......@@ -279,6 +279,12 @@ describe Project do
end
end
it 'validates presence of project_feature' do
project = build(:project, project_feature: nil)
expect(project).not_to be_valid
end
describe 'import_url' do
it 'does not allow an invalid URI as import_url' do
project = build(:project, import_url: 'invalid://')
......
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