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.
This commit is contained in:
Paul Beckingham 2009-11-28 09:53:15 -05:00
parent b7726bce21
commit b5f65850f8
3 changed files with 77 additions and 0 deletions

View file

@ -7,6 +7,8 @@
changes. Now task asks "Proceed with change? (Yes/no/all/quit)". changes. Now task asks "Proceed with change? (Yes/no/all/quit)".
+ Fixed bug #321 where all shell input was converted to lower case (thanks + Fixed bug #321 where all shell input was converted to lower case (thanks
to Juergen Daubert). to Juergen Daubert).
+ Fixed bug #327 that allowed the removal of a due date from a recurring
task.
------ old releases ------------------------------ ------ old releases ------------------------------

View file

@ -950,6 +950,15 @@ int handleModify (std::string &outs)
!task->has ("recur")) !task->has ("recur"))
throw std::string ("You cannot specify an until date for a non-recurring task."); 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. // Make all changes.
foreach (other, all) foreach (other, all)
{ {

66
src/tests/bug.327.t Executable file
View file

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