From 39c52e03b4acfd879dd0f0d70c603ced3c9fb940 Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Sun, 23 Feb 2014 14:03:57 +0100 Subject: [PATCH] fix failing tests the date in fixtures is not set by timecop. That doesn't help here --- test/controllers/todos_controller_test.rb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/test/controllers/todos_controller_test.rb b/test/controllers/todos_controller_test.rb index e13ca359..8540d450 100644 --- a/test/controllers/todos_controller_test.rb +++ b/test/controllers/todos_controller_test.rb @@ -715,13 +715,15 @@ class TodosControllerTest < ActionController::TestCase end def test_toggle_check_on_rec_todo_show_from_today - Timecop.travel(Time.local(2014, 1, 15)) do + Timecop.travel(2014, 1, 15) do login_as(:admin_user) # link todo_1 and recurring_todo_1 recurring_todo_1 = RecurringTodo.find(1) todo_1 = Todo.where(:recurring_todo_id => 1).first - today = Time.zone.now.at_midnight - 1.day + today = Time.zone.now.at_midnight + todo_1.due = today + assert todo_1.save # change recurrence pattern to monthly and set show_from to today recurring_todo_1.target = 'show_from_date' @@ -738,17 +740,14 @@ class TodosControllerTest < ActionController::TestCase # locate the new todo in tickler new_todo = Todo.where(:recurring_todo_id => recurring_todo_1.id, :state => 'deferred').first - assert !new_todo.nil? + assert !new_todo.nil?, "the todo should be in the tickler" assert_equal "Call Bill Gates every day", new_todo.description - # 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 in the tickler to show next month - assert !new_todo.show_from.nil? + assert_not_equal todo_1.id, new_todo.id, "check that the new todo is not the same as todo_1" + 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. - next_month = (Time.zone.now - 1.day + 1.month).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) end