fix failing tests

the date in fixtures is not set by timecop. That doesn't help here
This commit is contained in:
Reinier Balt 2014-02-23 14:03:57 +01:00
parent a14686d1e2
commit 39c52e03b4

View file

@ -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