several fixes to recurring todos and adds some named_scopes

fixes case where unmarking a complete todo which belongs to a recurring pattern results in two todos that both keep on recurring. With this fix a new todo will only be created when there are no active todos left belonging to that recurring pattern

fixes tests that failed because of previous commits

adds some named_scopes, inspired by http://railscasts.com/episodes/108
This commit is contained in:
Reinier Balt 2008-11-28 16:39:50 +01:00
parent bd2b410c7b
commit 4a98ee5669
8 changed files with 55 additions and 31 deletions

View file

@ -4,7 +4,10 @@ class Todo < ActiveRecord::Base
belongs_to :project
belongs_to :user
belongs_to :recurring_todo
named_scope :active, :conditions => { :state => 'active' }
named_scope :not_completed, :conditions => ['NOT state = ? ', 'completed']
STARRED_TAG_NAME = "starred"
acts_as_state_machine :initial => :active, :column => 'state'