プロジェクト

全般

プロフィール

Vote #78841

完了

Project identifier model constraint doesn't match with text_project_identifier_info and JS-generated identifiers

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Project settings_43
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
43
version_id:
127
issue_org_id:
27101
author_id:
1565
assigned_to_id:
1
comments:
3
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

I was looking at the project identifier constraint today and noticed a discrepancy between:

  • the text of @text_project_identifier_info@ (Only lower case letters (a-z), numbers, dashes and underscores are allowed, must start with a lower case letter.
    Once saved, the identifier cannot be changed.
    )
  • the auto-generated identifiers from #9225

and the actual enforced model constraint for the project identifier (@/\A(?!\d+$)[a-z0-9-_]*\z/@).

Based on the model constraint, project identifiers starting with a:

  • number
  • dash
  • underscore

are allowed and seem to work properly. This can be tested by adding the following test assertions to @ProjectTest#test_validate_identifier@:


diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb
index 24f6958..a0bd95f 100644
--- a/test/unit/project_test.rb
+++ b/test/unit/project_test.rb
@@ -116,7 +116,10 @@ class ProjectTest < ActiveSupport::TestCase
                "ab-12" => true,
                "ab_12" => true,
                "12" => false,
-               "new" => false}
+               "new" => false,
+               "12ab" => true,
+               "-12ab" => true,
+               "_12ab" => true}

     to_test.each do |identifier, valid|
       p = Project.new

Despite the textual hint and the auto-generated project identifiers, the above given test assertions succeed without any problems.

IMO there are two ways of solving this:

change the model constraint to match the textual hint and JS-project identifier generation script — that is to not allow project identifiers starting with a number, dash or underscore;

change the textual hint and JS-project identifier generation script to match the actual model constraint — which is to allow project identifiers starting with a number, dash or underscore.

I think that the second solution is the best, because that won't affect already existing projects with identifiers starting with these characters. I'd like to get some feedback on this matter before we make a change either way.


journals

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Thanks for pointing this out. I've updated the information messages that were obviously wrong.
OTOH, I think it's OK to keep the JS code as it is. Even if not mandatory, it's better to default to an identifier that starts with a lower case letter.
--------------------------------------------------------------------------------


related_issues

relates,Closed,9225,Generate project identifier automatically with JavaScript

Admin Redmine さんが約4年前に更新

  • カテゴリProject settings_43 にセット
  • 対象バージョン4.1.0_127 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0