]> source.dussan.org Git - redmine.git/commitdiff
Skip validation if attribute did not change.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 7 Jan 2015 22:51:45 +0000 (22:51 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 7 Jan 2015 22:51:45 +0000 (22:51 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@13851 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/role.rb

index 2db77a1a03db887a95c4ac8f4837f229d0420109..87fb1f6ad7f961fd9f86e97c3e245b2479642423 100644 (file)
@@ -71,10 +71,10 @@ class Role < ActiveRecord::Base
   validates_length_of :name, :maximum => 30
   validates_inclusion_of :issues_visibility,
     :in => ISSUES_VISIBILITY_OPTIONS.collect(&:first),
-    :if => lambda {|role| role.respond_to?(:issues_visibility)}
+    :if => lambda {|role| role.respond_to?(:issues_visibility) && role.issues_visibility_changed?}
   validates_inclusion_of :users_visibility,
     :in => USERS_VISIBILITY_OPTIONS.collect(&:first),
-    :if => lambda {|role| role.respond_to?(:users_visibility)}
+    :if => lambda {|role| role.respond_to?(:users_visibility) && role.users_visibility_changed?}
 
   # Copies attributes from another role, arg can be an id or a Role
   def copy_from(arg, options={})