diff --git a/app/models/recurring_todo.rb b/app/models/recurring_todo.rb index ab9fa3f1..ba40527e 100644 --- a/app/models/recurring_todo.rb +++ b/app/models/recurring_todo.rb @@ -508,7 +508,13 @@ class RecurringTodo < ActiveRecord::Base if previous.nil? start = self.start_from.nil? ? Time.now.utc : self.start_from else - start = previous + if self.start_from.nil? + start = previous + else + # check if the start_from date is later than previous. If so, use + # start_from as start to search for next date + start = self.start_from > previous ? self.start_from : previous + end end day = self.every_other1 diff --git a/test/unit/recurring_todo_test.rb b/test/unit/recurring_todo_test.rb index f3fccbbd..4ef86ddd 100644 --- a/test/unit/recurring_todo_test.rb +++ b/test/unit/recurring_todo_test.rb @@ -203,6 +203,13 @@ class RecurringTodoTest < Test::Rails::TestCase due_date1 = @yearly.get_due_date(nil) due_date2 = @yearly.get_due_date(Time.now.utc + 1.day) assert_equal due_date1, due_date2 + end + + def test_start_from_in_future + # start from after june 8th 2008 + @yearly.start_from = Time.utc(2008,6,12) + assert_equal Time.utc(2009,6,8), @yearly.get_due_date(nil) # jun 8th next year + assert_equal Time.utc(2009,6,8), @yearly.get_due_date(Time.utc(2008,6,1)) # also next year this_year = Time.now.utc.year @yearly.start_from = Time.utc(this_year+1,6,12)