From: Jean-Philippe Lang Date: Wed, 7 Jan 2015 22:51:45 +0000 (+0000) Subject: Skip validation if attribute did not change. X-Git-Tag: 3.0.0~161 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0eda7765fa55eee98646152278b7ef976f49e7c8;p=redmine.git Skip validation if attribute did not change. git-svn-id: http://svn.redmine.org/redmine/trunk@13851 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/models/role.rb b/app/models/role.rb index 2db77a1a0..87fb1f6ad 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -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={})