From ad953fe80b000e9bfca5ec1dfc3b83c33d559224 Mon Sep 17 00:00:00 2001 From: Henrik Bohre Date: Sun, 16 Aug 2009 00:32:35 +0200 Subject: [PATCH] #300: Updated todo fsm with guards that prevent activation if uncompleted predecessors exists --- app/models/todo.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/todo.rb b/app/models/todo.rb index 0eb9be78..b5bc0353 100644 --- a/app/models/todo.rb +++ b/app/models/todo.rb @@ -43,8 +43,9 @@ class Todo < ActiveRecord::Base event :activate do transitions :to => :active, :from => [:project_hidden, :completed, :deferred] transitions :to => :active, :from => [:pending], - :guard => Proc.new{|t| t.show_from.blank? or Time.zone.now > t.show_from} - transitions :to => :deferred, :from => [:pending] + :guard => Proc.new{|t| t.show_from.blank? or Time.zone.now > t.show_from and t.uncompleted_predecessors.empty?} + transitions :to => :deferred, :from => [:pending], + :guard => Proc.new{|t| t.uncompleted_predecessors.empty?} end event :hide do