diff --git a/test/functional/todos_controller_test.rb b/test/functional/todos_controller_test.rb index 2adf747b..cd4fba01 100644 --- a/test/functional/todos_controller_test.rb +++ b/test/functional/todos_controller_test.rb @@ -5,7 +5,7 @@ require 'todos_controller' class TodosController; def rescue_action(e) raise e end; end class TodosControllerTest < Test::Rails::TestCase - fixtures :users, :preferences, :projects, :contexts, :todos, :tags, :taggings + fixtures :users, :preferences, :projects, :contexts, :todos, :tags, :taggings, :recurring_todos def setup @controller = TodosController.new @@ -376,6 +376,24 @@ class TodosControllerTest < Test::Rails::TestCase # check there is a new todo linked to the recurring pattern next_todo = Todo.find(:first, :conditions => {:recurring_todo_id => recurring_todo_1.id, :state => 'active'}) assert_equal "Call Bill Gates every day", next_todo.description + + # change recurrence pattern to weekly and set show_from 2 days befor due date + # this forces the next todo to be put in the tickler + recurring_todo_1.show_from_delta = 2 + recurring_todo_1.recurring_period = 'weekly' + recurring_todo_1.every_day = 'smtwtfs' + recurring_todo_1.save + + # mark next_todo as complete by toggle_check + xhr :post, :toggle_check, :id => next_todo.id, :_source_view => 'todo' + next_todo.reload + assert next_todo.completed? + + # check there is a new todo linked to the recurring pattern in the tickler + next_todo = Todo.find(:first, :conditions => {:recurring_todo_id => recurring_todo_1.id, :state => 'deferred'}) + assert_equal "Call Bill Gates every day", next_todo.description + # check that the todo is in the tickler + assert !next_todo.show_from.nil? end - + end