mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 23:30:12 +01:00
hopefully fix failing recurring todos test. Timezones are a pain to get right
This commit is contained in:
parent
833297b355
commit
4b6aff5502
3 changed files with 97 additions and 95 deletions
|
|
@ -177,9 +177,9 @@ class ApplicationController < ActionController::Base
|
|||
def create_todo_from_recurring_todo(rt, date=nil)
|
||||
# create todo and initialize with data from recurring_todo rt
|
||||
todo = current_user.todos.build( { :description => rt.description, :notes => rt.notes, :project_id => rt.project_id, :context_id => rt.context_id})
|
||||
todo.recurring_todo_id = rt.id
|
||||
|
||||
# set dates
|
||||
todo.recurring_todo_id = rt.id
|
||||
todo.due = rt.get_due_date(date)
|
||||
|
||||
show_from_date = rt.get_show_from_date(date)
|
||||
|
|
|
|||
|
|
@ -737,8 +737,9 @@ class RecurringTodo < ActiveRecord::Base
|
|||
|
||||
protected
|
||||
|
||||
def determine_start(previous, offset=0.day)
|
||||
# Determine start date to calculate next date for recurring todo
|
||||
# offset needs to be 1.day for daily patterns
|
||||
def determine_start(previous, offset=0.day)
|
||||
|
||||
if previous.nil?
|
||||
start = self.start_from.nil? ? Time.zone.now : self.start_from
|
||||
|
|
@ -747,12 +748,11 @@ class RecurringTodo < ActiveRecord::Base
|
|||
else
|
||||
start = previous + offset
|
||||
|
||||
unless self.start_from.nil?
|
||||
# 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 if self.start_from > previous
|
||||
end
|
||||
start = self.start_from if ( self.start_from && self.start_from > previous )
|
||||
end
|
||||
|
||||
return start
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -530,7 +530,9 @@ class TodosControllerTest < ActionController::TestCase
|
|||
# check that the new_todo is in the tickler to show next month
|
||||
assert !new_todo.show_from.nil?
|
||||
|
||||
next_month = today + 1.month
|
||||
# do not use today here. It somehow gets messed up with the timezone calculation.
|
||||
next_month = (Time.zone.now + 1.month).at_midnight
|
||||
|
||||
assert_equal next_month.utc.to_date.to_s(:db), new_todo.show_from.utc.to_date.to_s(:db)
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue