Revert breaking commits

This reverts the following commits:
c129b8a06f
c7c923a317
006c135a64
This commit is contained in:
Dan Rice 2015-04-14 22:26:07 -04:00
parent aa14a8e802
commit 556c68c2e6
6 changed files with 63 additions and 63 deletions

View file

@ -1055,7 +1055,7 @@ end
if recurring_todo.todos.active.count == 0 if recurring_todo.todos.active.count == 0
# check for next todo either from the due date or the show_from date # check for next todo either from the due date or the show_from date
date_to_check = todo.due.nil? ? todo.show_from.localtime : todo.due.localtime date_to_check = todo.due.nil? ? todo.show_from : todo.due
# if both due and show_from are nil, check for a next todo from now # if both due and show_from are nil, check for a next todo from now
date_to_check = Time.zone.now if date_to_check.nil? date_to_check = Time.zone.now if date_to_check.nil?

View file

@ -93,7 +93,7 @@ module RecurringTodos
# TODO: recheck if future rails versions have this problem too # TODO: recheck if future rails versions have this problem too
start = Time.utc(start.year, start.month, start.day)+n.months start = Time.utc(start.year, start.month, start.day)+n.months
end end
Time.zone.local(start.year, start.month, every_x_day).localtime.at_midnight Time.zone.local(start.year, start.month, every_x_day)
end end
def find_relative_day_of_month(start, n) def find_relative_day_of_month(start, n)

View file

@ -379,9 +379,9 @@ class RecurringTodosControllerTest < ActionController::TestCase
"tag_list"=>"one, two, three, four", format: :js "tag_list"=>"one, two, three, four", format: :js
assert_equal "new recurring pattern", assigns['recurring_todo'].description assert_equal "new recurring pattern", assigns['recurring_todo'].description
assert_equal "2013-01-02", assigns['recurring_todo'].start_from.localtime.to_date.to_s assert_equal "2013-01-02 00:00:00 +0000", assigns['recurring_todo'].start_from.to_s
todo = assigns['recurring_todo'].todos.first todo = assigns['recurring_todo'].todos.first
assert_equal "2013-01-02", todo.show_from.localtime.to_date.to_s assert_equal "2013-01-02 00:00:00 +0000", todo.show_from.to_s
end end
end end

View file

@ -49,7 +49,7 @@ class StatsControllerTest < ActionController::TestCase
totals = assigns['stats'].totals totals = assigns['stats'].totals
assert_equal 4, totals.tags assert_equal 4, totals.tags
assert_equal 2, totals.unique_tags assert_equal 2, totals.unique_tags
assert_equal 2.weeks.ago.localtime.at_midnight, totals.first_action_at.localtime.at_midnight assert_equal 2.week.ago.utc.at_midnight, totals.first_action_at.utc.at_midnight
end end
def test_downdrill def test_downdrill

View file

@ -740,14 +740,14 @@ class TodosControllerTest < ActionController::TestCase
# locate the new todo in tickler # locate the new todo in tickler
new_todo = Todo.where(:recurring_todo_id => recurring_todo_1.id, :state => 'deferred').first new_todo = Todo.where(:recurring_todo_id => recurring_todo_1.id, :state => 'deferred').first
refute new_todo.nil?, "the todo should be in the tickler" assert !new_todo.nil?, "the todo should be in the tickler"
assert_equal "Call Bill Gates every day", new_todo.description assert_equal "Call Bill Gates every day", new_todo.description
assert_not_equal todo_1.id, new_todo.id, "check that the new todo is not the same as todo_1" assert_not_equal todo_1.id, new_todo.id, "check that the new todo is not the same as todo_1"
refute new_todo.show_from.nil?, "check that the new_todo is in the tickler to show next month" assert !new_todo.show_from.nil?, "check that the new_todo is in the tickler to show next month"
# do not use today here. It somehow gets messed up with the timezone calculation. # do not use today here. It somehow gets messed up with the timezone calculation.
next_month = (today + 1.month).localtime.at_midnight 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) assert_equal next_month.utc.to_date.to_s(:db), new_todo.show_from.utc.to_date.to_s(:db)
end end

View file

@ -121,9 +121,9 @@ module RecurringTodos
def test_determine_start def test_determine_start
travel_to Time.zone.local(2013,1,1) do travel_to Time.zone.local(2013,1,1) do
rt = create_recurring_todo rt = create_recurring_todo
assert_equal "2013-01-01", rt.send(:determine_start, nil).to_date.to_s(:db), "no previous date, use today" assert_equal "2013-01-01 00:00:00", rt.send(:determine_start, nil).to_s(:db), "no previous date, use today"
assert_equal "2013-01-01", rt.send(:determine_start, nil, 1.day).to_date.to_s(:db), "no previous date, use today without offset" assert_equal "2013-01-01 00:00:00", rt.send(:determine_start, nil, 1.day).to_s(:db), "no previous date, use today without offset"
assert_equal "2013-01-02", rt.send(:determine_start, Time.zone.now, 1.day).to_date.to_s(:db), "use previous date and offset" assert_equal "2013-01-02 00:00:00", rt.send(:determine_start, Time.zone.now, 1.day).to_s(:db), "use previous date and offset"
end end
end end
@ -131,14 +131,14 @@ module RecurringTodos
rt = create_recurring_todo rt = create_recurring_todo
# march 2014 has 5 saturdays, the last will return the 5th # march 2014 has 5 saturdays, the last will return the 5th
assert_equal "2014-03-01", rt.send(:get_xth_day_of_month, 1, 6, 3, 2014).to_date.to_s(:db) assert_equal "2014-03-01 00:00:00", rt.send(:get_xth_day_of_month, 1, 6, 3, 2014).to_s(:db)
assert_equal "2014-03-22", rt.send(:get_xth_day_of_month, 4, 6, 3, 2014).to_date.to_s(:db) assert_equal "2014-03-22 00:00:00", rt.send(:get_xth_day_of_month, 4, 6, 3, 2014).to_s(:db)
assert_equal "2014-03-29", rt.send(:get_xth_day_of_month, 5, 6, 3, 2014).to_date.to_s(:db) assert_equal "2014-03-29 00:00:00", rt.send(:get_xth_day_of_month, 5, 6, 3, 2014).to_s(:db)
# march 2014 has 4 fridays, the last will return the 4th # march 2014 has 4 fridays, the last will return the 4th
assert_equal "2014-03-07", rt.send(:get_xth_day_of_month, 1, 5, 3, 2014).to_date.to_s(:db) assert_equal "2014-03-07 00:00:00", rt.send(:get_xth_day_of_month, 1, 5, 3, 2014).to_s(:db)
assert_equal "2014-03-28", rt.send(:get_xth_day_of_month, 4, 5, 3, 2014).to_date.to_s(:db) assert_equal "2014-03-28 00:00:00", rt.send(:get_xth_day_of_month, 4, 5, 3, 2014).to_s(:db)
assert_equal "2014-03-28", rt.send(:get_xth_day_of_month, 5, 5, 3, 2014).to_date.to_s(:db) assert_equal "2014-03-28 00:00:00", rt.send(:get_xth_day_of_month, 5, 5, 3, 2014).to_s(:db)
assert_raise(RuntimeError, "should check on valid weekdays"){ rt.send(:get_xth_day_of_month, 5, 9, 3, 2014) } assert_raise(RuntimeError, "should check on valid weekdays"){ rt.send(:get_xth_day_of_month, 5, 9, 3, 2014) }
assert_raise(RuntimeError, "should check on valid count x"){ rt.send(:get_xth_day_of_month, 6, 5, 3, 2014) } assert_raise(RuntimeError, "should check on valid count x"){ rt.send(:get_xth_day_of_month, 6, 5, 3, 2014) }