From 2c0298472172f46880e56a7cf9d6760356c0be99 Mon Sep 17 00:00:00 2001 From: Gregor Schmidt Date: Tue, 19 Apr 2011 09:40:32 +0200 Subject: [PATCH] allowing 0 values for story points --- lib/backlogs_issue_patch.rb | 8 ++++---- spec/models/issue_spec.rb | 13 ++++--------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/backlogs_issue_patch.rb b/lib/backlogs_issue_patch.rb index fd820dd881..428c8d5bc1 100644 --- a/lib/backlogs_issue_patch.rb +++ b/lib/backlogs_issue_patch.rb @@ -14,10 +14,10 @@ module Backlogs before_validation :backlogs_before_validation, :if => lambda {|i| i.project && i.project.module_enabled?("backlogs")} after_save :backlogs_after_save - validates_numericality_of :story_points, :only_integer => true, - :allow_nil => true, - :greater_than => 0, - :less_than => 10_000, + validates_numericality_of :story_points, :only_integer => true, + :allow_nil => true, + :greater_than_or_equal_to => 0, + :less_than => 10_000, :if => lambda { |i| i.project && i.project.module_enabled?('backlogs') } end diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index 3406c47483..7f270eb79b 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -27,7 +27,10 @@ describe Issue do issue.should be_valid end - it 'allows values greater than 0' do + it 'allows values greater than or equal to 0' do + issue.story_points = '0' + issue.should be_valid + issue.story_points = '1' issue.should be_valid end @@ -42,14 +45,6 @@ describe Issue do issue.should_not be_valid end - it 'disallows 0 and negative values' do - issue.story_points = '0' - issue.should_not be_valid - - issue.story_points = '-1' - issue.should_not be_valid - end - it 'disallows greater or equal than 10.000' do issue.story_points = '10000' issue.should_not be_valid