From ae11f09d2fc351b192028b779b31b6c238fb047e Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Mon, 23 Sep 2013 16:52:29 +0200 Subject: [PATCH] fix calendar_test todos in rest of month means all todos after next week in the current month. The test failed if the todo was created in next week and that week being the last week in the month. In that case the todo should not be returned by rest_of_month since it is in rest_of_week --- test/models/todos/calendar_test.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/test/models/todos/calendar_test.rb b/test/models/todos/calendar_test.rb index 8ac6f7ec..5148f47c 100644 --- a/test/models/todos/calendar_test.rb +++ b/test/models/todos/calendar_test.rb @@ -32,10 +32,21 @@ module Todos assert_equal [due_next_week], @calendar.due_next_week end - def test_due_this_month - due_this_month = create_todo(Time.zone.now.end_of_month) + def test_due_this_month_at_start_month + # should return 1 todo + Timecop.travel(2013,9,1) do + due_this_month = create_todo(Time.zone.now.end_of_month) + assert_equal [due_this_month], @calendar.due_this_month + end + end - assert_equal [due_this_month], @calendar.due_this_month + def test_due_this_month_at_end_month + # the todo is due next week and is thus left out for todos due rest + # of month (i.e. after next week, but in this month) + Timecop.travel(2013,9,23) do + due_this_month = create_todo(Time.zone.now.end_of_month) + assert_equal 0, @calendar.due_this_month.size + end end def test_due_after_this_month