diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-11-15 22:43:10 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-11-15 22:43:10 +0000 |
commit | 8b527ce24783acafa0c3148b1c45ea0251fae2d0 (patch) | |
tree | 250bac015e1d02ff44c5c97c144eee7a3bc0cd58 /app/models/version.rb | |
parent | e9e5d2e072f6da616149ff643f082fcdef46a222 (diff) | |
download | redmine-8b527ce24783acafa0c3148b1c45ea0251fae2d0.tar.gz redmine-8b527ce24783acafa0c3148b1c45ea0251fae2d0.zip |
Fixed version date validation (#12359).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10810 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/version.rb')
-rw-r--r-- | app/models/version.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/app/models/version.rb b/app/models/version.rb index d0fe02973..16db9f05c 100644 --- a/app/models/version.rb +++ b/app/models/version.rb @@ -33,6 +33,7 @@ class Version < ActiveRecord::Base validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => :not_a_date, :allow_nil => true validates_inclusion_of :status, :in => VERSION_STATUSES validates_inclusion_of :sharing, :in => VERSION_SHARINGS + validate :validate_version scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}} scope :open, :conditions => {:status => 'open'} @@ -275,4 +276,10 @@ class Version < ActiveRecord::Base progress end end + + def validate_version + if effective_date.nil? && @attributes['effective_date'].present? + errors.add :effective_date, :not_a_date + end + end end |