From b5f65850f8ce56625cd6f673851f163654b2493a Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 28 Nov 2009 09:53:15 -0500 Subject: [PATCH] Bug Fix - #327 Deleting due date on recurring task wraps to 1969 - Task now prevents removal of either a due date or a recurrence from a recurring task. --- ChangeLog | 2 ++ src/command.cpp | 9 +++++++ src/tests/bug.327.t | 66 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100755 src/tests/bug.327.t diff --git a/ChangeLog b/ChangeLog index 851f36d47..a0fec7283 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ changes. Now task asks "Proceed with change? (Yes/no/all/quit)". + Fixed bug #321 where all shell input was converted to lower case (thanks to Juergen Daubert). + + Fixed bug #327 that allowed the removal of a due date from a recurring + task. ------ old releases ------------------------------ diff --git a/src/command.cpp b/src/command.cpp index 4dab68b67..c359171c7 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -950,6 +950,15 @@ int handleModify (std::string &outs) !task->has ("recur")) throw std::string ("You cannot specify an until date for a non-recurring task."); + if (task->has ("due") && + !context.task.has ("due") && + context.task.has ("recur")) + throw std::string ("You cannot remove the due date from a recurring task."); + + if (task->has ("recur") && + !context.task.has ("recur")) + throw std::string ("You cannot remove the recurrence from a recurring task."); + // Make all changes. foreach (other, all) { diff --git a/src/tests/bug.327.t b/src/tests/bug.327.t new file mode 100755 index 000000000..de8340e0a --- /dev/null +++ b/src/tests/bug.327.t @@ -0,0 +1,66 @@ +#! /usr/bin/perl +################################################################################ +## task - a command line task list manager. +## +## Copyright 2006 - 2009, Paul Beckingham. +## All rights reserved. +## +## This program is free software; you can redistribute it and/or modify it under +## the terms of the GNU General Public License as published by the Free Software +## Foundation; either version 2 of the License, or (at your option) any later +## version. +## +## This program is distributed in the hope that it will be useful, but WITHOUT +## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +## details. +## +## You should have received a copy of the GNU General Public License along with +## this program; if not, write to the +## +## Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, +## Boston, MA +## 02110-1301 +## USA +## +################################################################################ + +use strict; +use warnings; +use Test::More tests => 6; + +# Create the rc file. +if (open my $fh, '>', 'bug.rc') +{ + print $fh "data.location=.\n", + "confirmation=no\n"; + close $fh; + ok (-r 'bug.rc', 'Created bug.rc'); +} + +# Setup: Add a recurring task then remove the due date. +qx{../task rc:bug.rc add foo recur:yearly due:eoy}; +qx{../task rc:bug.rc li}; +qx{../task rc:bug.rc 2 due:}; + +# Result: Somehow the due date is incremented and wraps around to 12/31/1969, +# then keeps going back to today. +my $output = qx{../task rc:bug.rc li}; +like ($output, qr/^1 task$/ms, 'Should only be one task'); + +# Cleanup. +unlink 'pending.data'; +ok (!-r 'pending.data', 'Removed pending.data'); + +unlink 'completed.data'; +ok (!-r 'completed.data', 'Removed completed.data'); + +unlink 'undo.data'; +ok (!-r 'undo.data', 'Removed undo.data'); + +unlink 'bug.rc'; +ok (!-r 'bug.rc', 'Removed bug.rc'); + +exit 0; +