From 5567b04277631aeb8b8c2558b1182776de10df03 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 5 Feb 2010 18:34:12 -0500 Subject: [PATCH] Bug Fix - #370 - Task was preventing removal of due date from any task that had a due date, which is wrong. It should be any task with a recur: value and a due date (thanks to John Florian). --- ChangeLog | 3 +++ src/command.cpp | 3 ++- src/tests/bug.360.t | 13 ++++++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 53371d804..63998df6e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -77,6 +77,9 @@ epoch numbers instead of dates (thanks to Cory Donnelly). + Fixed bug #369 which prevented the config command from setting quoted or unquoted multi-word values (thanks to Richard Querin). + + Fixed bug #370 which prevented the removal of a due date from a task, + mis-identifying the task as recurring just because it had a due date + (thanks to John Florian). ------ old releases ------------------------------ diff --git a/src/command.cpp b/src/command.cpp index 54b1272f6..851bec072 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -1300,7 +1300,8 @@ 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") && + if (task->has ("recur") && + task->has ("due") && context.task.has ("due") && context.task.get ("due") == "") throw std::string ("You cannot remove the due date from a recurring task."); diff --git a/src/tests/bug.360.t b/src/tests/bug.360.t index 2bdfbfba1..8ea013533 100755 --- a/src/tests/bug.360.t +++ b/src/tests/bug.360.t @@ -28,7 +28,7 @@ use strict; use warnings; -use Test::More tests => 7; +use Test::More tests => 9; # Create the rc file. if (open my $fh, '>', 'bug.rc') @@ -53,6 +53,17 @@ unlike ($output, qr/You cannot remove the recurrence from a recurring task./ms, $output = qx{../task rc:bug.rc 2 recur:}; like ($output, qr/You cannot remove the recurrence from a recurring task./ms, 'Recurrence removal error'); +# Prevent removal of the due date from a recurring task. +$output = qx{../task rc:bug.rc 2 due:}; +like ($output, qr/You cannot remove the due date from a recurring task./ms, 'Cannot remove due date from a recurring task'); + +# Allow removal of the due date from a non-recurring task. +qx{../task rc:bug.rc add nonrecurring}; +$output = qx{../task rc:bug.rc ls}; +my ($id) = $output =~ /(\d+)\s+nonrecurring/; +$output = qx{../task rc:bug.rc $id due:}; +unlike ($output, qr/You cannot remove the due date from a recurring task./ms, 'Can remove due date from a non-recurring task'); + # Cleanup. unlink 'pending.data'; ok (!-r 'pending.data', 'Removed pending.data');