]> source.dussan.org Git - redmine.git/commitdiff
Skip some validations if attribute did not change.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 6 Dec 2014 11:23:05 +0000 (11:23 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 6 Dec 2014 11:23:05 +0000 (11:23 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@13723 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue.rb
app/models/project.rb

index 4dcc69a47c895c72fd63d03dbc71bb7f1b7c1c74..a23d4bd9fb5c9a326c7497fd3eba1f249b562d87 100644 (file)
@@ -66,7 +66,10 @@ class Issue < ActiveRecord::Base
   attr_reader :current_journal
   delegate :notes, :notes=, :private_notes, :private_notes=, :to => :current_journal, :allow_nil => true
 
-  validates_presence_of :subject, :priority, :project, :tracker, :author, :status
+  validates_presence_of :subject, :project, :tracker
+  validates_presence_of :priority, :if => Proc.new {|issue| issue.new_record? || issue.priority_id_changed?}
+  validates_presence_of :status, :if => Proc.new {|issue| issue.new_record? || issue.status_id_changed?}
+  validates_presence_of :author, :if => Proc.new {|issue| issue.new_record? || issue.author_id_changed?}
 
   validates_length_of :subject, :maximum => 255
   validates_inclusion_of :done_ratio, :in => 0..100
index 961fb5bfcd9c5588a424e76e4a1caff74231fc7c..f7cfc65e00e799171a0e9782124569341379e0e3 100644 (file)
@@ -72,8 +72,7 @@ class Project < ActiveRecord::Base
   attr_protected :status
 
   validates_presence_of :name, :identifier
-  validates_uniqueness_of :identifier
-  validates_associated :repository, :wiki
+  validates_uniqueness_of :identifier, :if => Proc.new {|p| p.identifier_changed?}
   validates_length_of :name, :maximum => 255
   validates_length_of :homepage, :maximum => 255
   validates_length_of :identifier, :in => 1..IDENTIFIER_MAX_LENGTH