]> source.dussan.org Git - redmine.git/commitdiff
Prevent creation of project with identifier 'new' (#3602).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 18 Jul 2009 08:06:51 +0000 (08:06 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 18 Jul 2009 08:06:51 +0000 (08:06 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2821 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/project.rb
test/unit/project_test.rb

index 8799e3b5847eacfc65cd57f8202efd78713bf553..0b0c47a2432f6d5afee4f3bd09e684b9383228e8 100644 (file)
@@ -63,7 +63,9 @@ 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
 
   named_scope :has_module, lambda { |mod| { :conditions => ["#{Project.table_name}.id IN (SELECT em.project_id FROM #{EnabledModule.table_name} em WHERE em.name=?)", mod.to_s] } }
index 2c874585660a43f5b47b128164d2be3c83a3f1d4..60bc4f1c17a0ffa2991cdba915be6620af96a2fa 100644 (file)
@@ -52,7 +52,8 @@ class ProjectTest < Test::Unit::TestCase
     to_test = {"abc" => true,\r
                "ab12" => true,\r
                "ab-12" => true,\r
-               "12" => false}\r
+               "12" => false,\r
+               "new" => false}\r
                \r
     to_test.each do |identifier, valid|\r
       p = Project.new\r