diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index 2e3ac3c5..3bebf14e 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -675,8 +675,9 @@ class TodosController < ApplicationController @recurring_todo = nil if @todo.from_recurring_todo? @recurring_todo = current_user.recurring_todos.find(@todo.recurring_todo_id) - if @recurring_todo.active? && @recurring_todo.has_next_todo(@todo.due) - date = @todo.due >= Date.today() ? @todo.due : Date.today()-1.day + date_to_check = @todo.due.nil? ? @todo.show_from : @todo.due + if @recurring_todo.active? && @recurring_todo.has_next_todo(date_to_check) + date = date_to_check >= Date.today() ? date_to_check : Date.today()-1.day @new_recurring_todo = create_todo_from_recurring_todo(@recurring_todo, date) end end diff --git a/app/models/recurring_todo.rb b/app/models/recurring_todo.rb index 66012735..ab9fa3f1 100644 --- a/app/models/recurring_todo.rb +++ b/app/models/recurring_todo.rb @@ -466,7 +466,7 @@ class RecurringTodo < ActiveRecord::Base when 1 # relative weekday of a month the_next = get_xth_day_of_month(self.every_other3, self.every_count, start.month, start.year) - if the_next.nil? || the_next < start + if the_next.nil? || the_next <= start # the nth day is already passed in this month, go to next month and try # again the_next = the_next+n.months diff --git a/test/unit/recurring_todo_test.rb b/test/unit/recurring_todo_test.rb index 155b9112..068bb35c 100644 --- a/test/unit/recurring_todo_test.rb +++ b/test/unit/recurring_todo_test.rb @@ -74,6 +74,7 @@ class RecurringTodoTest < Test::Rails::TestCase # check show from get the next day assert_equal @today, @every_day.get_show_from_date(@today-1.days) + assert_equal @today+1.day, @every_day.get_show_from_date(@today) @every_day.target='due_date' # when target on due_date, show_from is relative to due date unless delta=0 @@ -144,9 +145,9 @@ class RecurringTodoTest < Test::Rails::TestCase def test_monthly_pattern due_date = @monthly_every_last_friday.get_due_date(@sunday) assert_equal Time.utc(2008,6,27), due_date - + friday_is_last_day_of_month = Time.utc(2008,10,31) - due_date = @monthly_every_last_friday.get_due_date(friday_is_last_day_of_month ) + due_date = @monthly_every_last_friday.get_due_date(friday_is_last_day_of_month-1.day ) assert_equal friday_is_last_day_of_month , due_date @monthly_every_third_friday = @monthly_every_last_friday