OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#37299] Remove validation for project identifier presence (#9296)
Oliver Güntherc9a80b86530d
diff --git a/app/models/project.rb b/app/models/project.rbindex 3e4aa2823c2..6410f7f84e4 100644--- a/app/models/project.rb+++ b/app/models/project.rb@@ -124,7 +124,8 @@ class Project < ApplicationRecordpresence: true,uniqueness: { case_sensitive: true },length: { maximum: IDENTIFIER_MAX_LENGTH },- exclusion: RESERVED_IDENTIFIERS+ exclusion: RESERVED_IDENTIFIERS,+ if: ->(p) { p.persisted? || p.identifier.present? }validates_associated :repository, :wiki# starts with lower-case letter, a-z, 0-9, dashes and underscores afterwardsdiff --git a/spec/requests/api/v3/projects/copy/copy_resource_spec.rb b/spec/requests/api/v3/projects/copy/copy_resource_spec.rbindex d419d0a5e8e..48e316cfcdf 100644--- a/spec/requests/api/v3/projects/copy/copy_resource_spec.rb+++ b/spec/requests/api/v3/projects/copy/copy_resource_spec.rb@@ -83,12 +83,8 @@ describe ::API::V3::Projects::Copy::CopyAPI, content_type: :json do.at_path('_type')expect(response.body)- .to be_json_eql("Multiple field constraints have been violated.".to_json)+ .to be_json_eql("Name can't be blank.".to_json).at_path("message")-- errors = JSON.parse(response.body)['_embedded']['errors']- expect(errors.collect { |el| el['message'] })- .to contain_exactly "Identifier can't be blank.", "Name can't be blank."endenddiff --git a/spec/requests/api/v3/projects/create_form_resource_spec.rb b/spec/requests/api/v3/projects/create_form_resource_spec.rbindex fd7589b2076..e17e61610fb 100644--- a/spec/requests/api/v3/projects/create_form_resource_spec.rb+++ b/spec/requests/api/v3/projects/create_form_resource_spec.rb@@ -81,21 +81,10 @@ describe ::API::V3::Projects::CreateFormAPI, content_type: :json doendcontext 'with empty parameters' do- it 'has 2 validation errors' do- expect(subject.body).to have_json_size(2).at_path('_embedded/validationErrors')- end-- it 'has a validation error on name' do+ it 'has one validation error for name', :aggregate_failures do+ expect(subject.body).to have_json_size(1).at_path('_embedded/validationErrors')expect(subject.body).to have_json_path('_embedded/validationErrors/name')- end-- it 'has a validation error on identifier' do- expect(subject.body).to have_json_path('_embedded/validationErrors/identifier')- end-- it 'has no commit link' do- expect(subject.body)- .not_to have_json_path('_links/commit')+ expect(subject.body).not_to have_json_path('_links/commit')endenddiff --git a/spec_legacy/unit/project_spec.rb b/spec_legacy/unit/project_spec.rbindex bf2cd18be0b..aa4f88f919b 100644--- a/spec_legacy/unit/project_spec.rb+++ b/spec_legacy/unit/project_spec.rb@@ -39,9 +39,6 @@ describe Project, type: :model doendit { is_expected.to validate_presence_of :name }- it { is_expected.to validate_presence_of :identifier }-- it { is_expected.to validate_uniqueness_of :identifier }context 'associations' doit { is_expected.to have_many :members }