summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/project.rb4
-rw-r--r--test/unit/project_test.rb3
2 files changed, 5 insertions, 2 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 8799e3b58..0b0c47a24 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -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] } }
diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb
index 2c8745856..60bc4f1c1 100644
--- a/test/unit/project_test.rb
+++ b/test/unit/project_test.rb
@@ -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