From a5d8ef524e454e71b965842d29b7c480ed7ad188 Mon Sep 17 00:00:00 2001 From: Federico Hernandez Date: Tue, 23 Feb 2010 22:50:59 +0100 Subject: [PATCH] Bug Fix - #382 task annotate doesn't complain when a task id is omitted - added error msg when annotating without a task id --- ChangeLog | 6 ++---- src/command.cpp | 3 +++ src/tests/bug.annotate.t | 6 +++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index ccc531dc3..d1cea7545 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,9 @@ ------ current release --------------------------- -2.0.0 () - + The 'config' command now highlights problems in color. - ------- old releases ------------------------------ 1.9.1 () + + Fixed bugg #382 in which the annotate command didn't returned an + error message if called without an ID. ------ old releases ------------------------------ diff --git a/src/command.cpp b/src/command.cpp index 0f2a0c5ff..677a9077b 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -1887,6 +1887,9 @@ int handleAnnotate (std::string &outs) if (!context.task.has ("description")) throw std::string ("Cannot apply a blank annotation."); + if (!context.task.has ("id")) + throw std::string ("ID needed to apply an annotation."); + std::stringstream out; std::vector tasks; diff --git a/src/tests/bug.annotate.t b/src/tests/bug.annotate.t index 486df30f8..639cc4b3a 100755 --- a/src/tests/bug.annotate.t +++ b/src/tests/bug.annotate.t @@ -28,7 +28,7 @@ use strict; use warnings; -use Test::More tests => 5; +use Test::More tests => 6; # Create the rc file. if (open my $fh, '>', 'bug_annotate.rc') @@ -43,6 +43,10 @@ qx{../task rc:bug_annotate.rc add foo}; my $output = qx{../task rc:bug_annotate.rc 1 annotate}; like ($output, qr/Cannot apply a blank annotation./, 'failed on blank annotation'); +# Attempt an annotation without ID +$output = qx{../task rc:bug_annotate.rc annotate bar}; +like ($output, qr/ID needed to apply an annotation./, 'failed on annotation without ID'); + # Cleanup. unlink 'pending.data'; ok (!-r 'pending.data', 'Removed pending.data');