From 9d372ce6f5b1b6a5861e9f3c212ea805af9d2d37 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Fri, 27 Jan 2012 17:34:58 +0000 Subject: [PATCH] Allow underscores in project identifiers (#1363). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8708 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/project.rb | 2 +- config/locales/en-GB.yml | 2 +- config/locales/en.yml | 2 +- config/locales/fr.yml | 2 +- test/unit/project_test.rb | 1 + 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index 878b4c0ca..8a79ed674 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -76,7 +76,7 @@ class Project < ActiveRecord::Base validates_length_of :homepage, :maximum => 255 validates_length_of :identifier, :in => 1..IDENTIFIER_MAX_LENGTH # donwcase letters, digits, dashes but not digits only - validates_format_of :identifier, :with => /^(?!\d+$)[a-z0-9\-]*$/, :if => Proc.new { |p| p.identifier_changed? } + validates_format_of :identifier, :with => /^(?!\d+$)[a-z0-9\-_]*$/, :if => Proc.new { |p| p.identifier_changed? } # reserved words validates_exclusion_of :identifier, :in => %w( new ) diff --git a/config/locales/en-GB.yml b/config/locales/en-GB.yml index 66a6e0bed..9a5b8565a 100644 --- a/config/locales/en-GB.yml +++ b/config/locales/en-GB.yml @@ -879,7 +879,7 @@ en-GB: text_tip_issue_begin_day: task beginning this day text_tip_issue_end_day: task ending this day text_tip_issue_begin_end_day: task beginning and ending this day - text_project_identifier_info: 'Only lower case letters (a-z), numbers and dashes are allowed.
Once saved, the identifier cannot be changed.' + text_project_identifier_info: 'Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed.' text_caracters_maximum: "%{count} characters maximum." text_caracters_minimum: "Must be at least %{count} characters long." text_length_between: "Length between %{min} and %{max} characters." diff --git a/config/locales/en.yml b/config/locales/en.yml index 6ac30adec..e9f160db1 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -915,7 +915,7 @@ en: text_tip_issue_begin_day: issue beginning this day text_tip_issue_end_day: issue ending this day text_tip_issue_begin_end_day: issue beginning and ending this day - text_project_identifier_info: 'Only lower case letters (a-z), numbers and dashes are allowed.
Once saved, the identifier cannot be changed.' + text_project_identifier_info: 'Only lower case letters (a-z), numbers, dashes and underscores are allowed.
Once saved, the identifier cannot be changed.' text_caracters_maximum: "%{count} characters maximum." text_caracters_minimum: "Must be at least %{count} characters long." text_length_between: "Length between %{min} and %{max} characters." diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 562a488a7..e2029b591 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -882,7 +882,7 @@ fr: text_tip_issue_begin_day: tâche commençant ce jour text_tip_issue_end_day: tâche finissant ce jour text_tip_issue_begin_end_day: tâche commençant et finissant ce jour - text_project_identifier_info: 'Seuls les lettres minuscules (a-z), chiffres et tirets sont autorisés.
Un fois sauvegardé, l''identifiant ne pourra plus être modifié.' + text_project_identifier_info: 'Seuls les lettres minuscules (a-z), chiffres, tirets et underscore sont autorisés.
Un fois sauvegardé, l''identifiant ne pourra plus être modifié.' text_caracters_maximum: "%{count} caractères maximum." text_caracters_minimum: "%{count} caractères minimum." text_length_between: "Longueur comprise entre %{min} et %{max} caractères." diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb index b3fd3de24..2901b6efa 100644 --- a/test/unit/project_test.rb +++ b/test/unit/project_test.rb @@ -119,6 +119,7 @@ class ProjectTest < ActiveSupport::TestCase to_test = {"abc" => true, "ab12" => true, "ab-12" => true, + "ab_12" => true, "12" => false, "new" => false}