mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 23:30:12 +01:00
Bug repeating monthly recurring todos
This commit is contained in:
parent
eaa66be698
commit
a6c32889ce
2 changed files with 39 additions and 1 deletions
|
|
@ -489,7 +489,7 @@ class RecurringTodo < ActiveRecord::Base
|
||||||
|
|
||||||
case self.recurrence_selector
|
case self.recurrence_selector
|
||||||
when 0 # specific day of the month
|
when 0 # specific day of the month
|
||||||
if start.mday > day
|
if start.mday >= day
|
||||||
# there is no next day n in this month, search in next month
|
# there is no next day n in this month, search in next month
|
||||||
#
|
#
|
||||||
# start += n.months
|
# start += n.months
|
||||||
|
|
|
||||||
|
|
@ -799,6 +799,44 @@ class TodosControllerTest < ActionController::TestCase
|
||||||
assert next_todo.due > todo.due
|
assert next_todo.due > todo.due
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_check_for_next_todo_monthly
|
||||||
|
login_as :admin_user
|
||||||
|
|
||||||
|
tomorrow = Time.zone.now + 1.day
|
||||||
|
|
||||||
|
# Given a monthly repeat pattern
|
||||||
|
recurring_todo = RecurringTodo.find(5)
|
||||||
|
recurring_todo.target = "due_date"
|
||||||
|
recurring_todo.recurring_period = "monthly"
|
||||||
|
recurring_todo.every_other1 = tomorrow.day
|
||||||
|
recurring_todo.every_other2 = 1
|
||||||
|
recurring_todo.save
|
||||||
|
|
||||||
|
# Given a recurring todo (todo) that belongs to the repeat pattern (recurring_todo) and is due tomorrow
|
||||||
|
todo = Todo.where(:recurring_todo_id => 1).first
|
||||||
|
assert todo.from_recurring_todo?
|
||||||
|
todo.recurring_todo_id = 5 # rewire todo to the repeat pattern above
|
||||||
|
todo.due = tomorrow
|
||||||
|
todo.save!
|
||||||
|
|
||||||
|
# When I mark the todo complete
|
||||||
|
xhr :post, :toggle_check, :id => todo.id, :_source_view => 'todo'
|
||||||
|
todo.reload
|
||||||
|
assert todo.completed?
|
||||||
|
|
||||||
|
# Then there should not be an active todo beloning to the repeat pattern
|
||||||
|
next_todo = Todo.where(:recurring_todo_id => recurring_todo.id, :state => 'active').first
|
||||||
|
assert next_todo.nil?
|
||||||
|
|
||||||
|
# Then there should be one new deferred todo
|
||||||
|
next_todo = Todo.where(:recurring_todo_id => recurring_todo.id, :state => 'deferred').first
|
||||||
|
assert !next_todo.nil?
|
||||||
|
assert !next_todo.show_from.nil?
|
||||||
|
|
||||||
|
# check that the due date of the new todo is later than tomorrow
|
||||||
|
assert next_todo.due > todo.due
|
||||||
|
end
|
||||||
|
|
||||||
############
|
############
|
||||||
# todo notes
|
# todo notes
|
||||||
############
|
############
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue