[PATCH/foreman 1/1] fixes #1332 'setting puppet_interval to zero gives division by zero in the dashboard'

Signed-off-by: Florian Koch <florian.koch1981@googlemail.com>

··· --- app/models/setting.rb | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/app/models/setting.rb b/app/models/setting.rb
index 1a67ecd…43447c3 100644
— a/app/models/setting.rb
+++ b/app/models/setting.rb
@@ -9,6 +9,7 @@ class Setting < ActiveRecord::Base
validates_presence_of :default, :unless => Proc.new { |s| s.default == false } # broken validator
validates_uniqueness_of :name
validates_numericality_of :value, :if => Proc.new {|s| s.settings_type == “integer”}

  • validates_numericality_of :value, :if => Proc.new {|s| s.name == “puppet_interval”}, :greater_than => 0
    validates_inclusion_of :value, :in => [true,false], :if => Proc.new {|s| s.settings_type == “boolean”}
    validates_inclusion_of :settings_type, :in => TYPES, :allow_nil => true, :allow_blank => true
    before_validation :fix_types

    1.7.6.4