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
Remove too much spaces from the project name before saving it. Otherwise the spaces will cause problems later, e.g when trying to delete the project
Henriette Dargeb7ab9483ed0b
diff --git a/app/models/project.rb b/app/models/project.rbindex 62045ab20f9..c762f05136b 100644--- a/app/models/project.rb+++ b/app/models/project.rb@@ -155,6 +155,9 @@ class Project < ApplicationRecordvalidates :name,presence: true,length: { maximum: 255 }++ before_validation :remove_white_spaces_from_project_name+# TODO: we temporarily disable this validation because it leads to failed tests# it implicitly assumes a db:seed-created standard type to be present and currently# neither development nor deployment setups are prepared for this@@ -573,4 +576,8 @@ class Project < ApplicationRecord.includes(:project).references(:projects)end++ def remove_white_spaces_from_project_name+ self.name = name.squish unless self.name.nil?+ endenddiff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rbindex 688dcc3347c..5d562e42df3 100644--- a/spec/models/project_spec.rb+++ b/spec/models/project_spec.rb@@ -184,6 +184,18 @@ describe Project, type: :model doendend+ describe 'name' do+ let(:project) { FactoryBot.build_stubbed :project, name: ' Hello World '}++ before do+ project.valid?+ end++ it 'trims the name' do+ expect(project.name).to eql('Hello World')+ end+ end+describe '#types_used_by_work_packages' dolet(:project) { FactoryBot.create(:project_with_types) }let(:type) { project.types.first }