Prevent creation of project with identifier 'new' (#3602).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2821 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2009-07-18 08:06:51 +00:00
parent d41bd93acb
commit 36d8f35192
2 changed files with 5 additions and 2 deletions

View File

@ -63,6 +63,8 @@ class Project < ActiveRecord::Base
validates_length_of :identifier, :in => 1..20
# donwcase letters, digits, dashes but not digits only
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 )
before_destroy :delete_all_members

View File

@ -52,7 +52,8 @@ class ProjectTest < Test::Unit::TestCase
to_test = {"abc" => true,
"ab12" => true,
"ab-12" => true,
"12" => false}
"12" => false,
"new" => false}
to_test.each do |identifier, valid|
p = Project.new