0
@@ -406,6 +406,52 @@ class TodosControllerTest < Test::Rails::TestCase
0
# check that the todo is in the tickler
0
assert !next_todo.show_from.nil?
0
+ def test_toggle_check_on_rec_todo_show_from_today
0
+ # link todo_1 and recurring_todo_1
0
+ recurring_todo_1 = RecurringTodo.find(1)
0
+ todo_1 = Todo.find_by_recurring_todo_id(1)
0
+ today = Time.now.utc.at_midnight
0
+ # change recurrence pattern to monthly and set show_from to today
0
+ recurring_todo_1.target = 'show_from_date'
0
+ recurring_todo_1.recurring_period = 'monthly'
0
+ recurring_todo_1.recurrence_selector = 0
0
+ recurring_todo_1.every_other1 = today.day
0
+ recurring_todo_1.every_other2 = 1
0
+ # mark todo_1 as complete by toggle_check, this gets rid of todo_1 that was
0
+ # not correctly created from the adjusted recurring pattern we defined
0
+ xhr :post, :toggle_check, :id => todo_1.id, :_source_view => 'todo'
0
+ assert todo_1.completed?
0
+ # locate the new todo. This todo is created from the adjusted recurring
0
+ # pattern defined in this test
0
+ new_todo = Todo.find(:first, :conditions => {:recurring_todo_id => recurring_todo_1.id, :state => 'active'})
0
+ # mark new_todo as complete by toggle_check
0
+ xhr :post, :toggle_check, :id => new_todo.id, :_source_view => 'todo'
0
+ assert todo_1.completed?
0
+ # locate the new todo in tickler
0
+ new_todo = Todo.find(:first, :conditions => {:recurring_todo_id => recurring_todo_1.id, :state => 'deferred'})
0
+ assert_equal "Call Bill Gates every day", new_todo.description
0
+ # check that the new todo is not the same as todo_1
0
+ assert_not_equal todo_1.id, new_todo.id
0
+ # check that the new_todo is in the tickler to show next month
0
+ assert !new_todo.show_from.nil?
0
+ assert_equal Time.utc(today.year, today.month+1, today.day), new_todo.show_from
0
def test_check_for_next_todo