Signed-off-by: Benjamin LAN-SUN-LUK <benjamin.lan-sun-luk(a)supinfo.com>
---
app/controllers/sprints_controller.rb | 8 +++++++-
app/models/backlog_item.rb | 4 ++++
2 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/app/controllers/sprints_controller.rb
b/app/controllers/sprints_controller.rb
index df336ad..eaf35e3 100644
--- a/app/controllers/sprints_controller.rb
+++ b/app/controllers/sprints_controller.rb
@@ -167,7 +167,7 @@ class SprintsController < ApplicationController
@sprint.backlog_items << BacklogItem.new(
:sprint_id => @sprint.id,
:user_story_id => selected,
- :estimated_hours => estimate.to_f)
+ :estimated_hours => estimate)
end
end
@@ -177,6 +177,12 @@ class SprintsController < ApplicationController
else
@title = "Sprint #{(a)sprint.id} (Planning)"
flash[:error] = "There was an error updating the sprint
backlog."
+ @sprint.backlog_items.each do |backlog_item|
+ if backlog_item.errors['estimated_hours']
+ flash[:error] += ' ' +
backlog_item.errors['estimated_hours']
+ break
+ end
+ end
@user_stories = UserStory.find_all_by_product_id((a)product.id)
format.html { render :action => :plan }
end
diff --git a/app/models/backlog_item.rb b/app/models/backlog_item.rb
index d149172..5a88800 100644
--- a/app/models/backlog_item.rb
+++ b/app/models/backlog_item.rb
@@ -24,6 +24,10 @@ class BacklogItem < ActiveRecord::Base
validates_presence_of :user_story_id,
:message => 'You need to specify a user story.'
+ validates_numericality_of :estimated_hours,
+ :greater_than => 0,
+ :message => 'Estimated hours must be numeric and greater than 0.'
+
belongs_to :sprint
belongs_to :user_story
belongs_to :owner, :class_name => 'User', :foreign_key =>
'owner_id'
--
1.6.0.2