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
add a test for checking that all nested projects routes are reserved
Ivan Kuchin602c3b1be920
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rbindex d8d336a9a0e..2eb832f8960 100644--- a/spec/models/project_spec.rb+++ b/spec/models/project_spec.rb@@ -411,4 +411,33 @@ RSpec.describe Project dolet(:model_instance) { project }let(:custom_field) { create(:string_project_custom_field) }end++ describe "url identifier" do+ let(:reserved) do+ Rails.application.routes.routes+ .map { |route| route.path.spec.to_s }+ .filter_map { |path| path[%r{^/projects/(\w+)\(\.:format\)$}, 1] }+ .uniq+ end++ it "is set from name" do+ project = described_class.new(name: "foo")++ project.validate++ expect(project.identifier).to eq("foo")+ end++ it "is not allowed to clash with projects routing" do+ expect(reserved).not_to be_empty++ reserved.each do |word|+ project = described_class.new(name: word)++ project.validate++ expect(project.identifier).not_to eq(word)+ end+ end+ endend