From bf9e14f5817f9575e8de0822722d73f82a8f5986 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 29 Jan 2012 17:44:43 -0500 Subject: [PATCH] Bug 899 - Fixed bug #899, which displayed incorrect project completion numbers (thanks to Paul-Gheorghe Barbu). - Added unit tests. --- AUTHORS | 1 + ChangeLog | 2 ++ src/TDB2.cpp | 14 --------- src/commands/CmdLog.cpp | 1 - test/bug.899.t | 65 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 68 insertions(+), 15 deletions(-) create mode 100755 test/bug.899.t diff --git a/AUTHORS b/AUTHORS index 80459e45b..ec51e4fdc 100644 --- a/AUTHORS +++ b/AUTHORS @@ -118,4 +118,5 @@ suggestions: Aaron Jackson Dmitriy Samborskiy Eli Lev + Paul-Gheorghe Barbu diff --git a/ChangeLog b/ChangeLog index 9b7ead32b..6bba84c40 100644 --- a/ChangeLog +++ b/ChangeLog @@ -234,6 +234,8 @@ std::map::operator[] (thanks to Dmitriy Samborskiy). + Fixed bug #897, which adds the UUID field to the 'completed' report (thanks to Eli Lev). + + Fixed bug #899, which displayed incorrect project completion numbers (thanks + to Paul-Gheorghe Barbu). # Untracked Bugs, biggest first. + Fixed bug that required the '%YAML' prologue in a YAML import. diff --git a/src/TDB2.cpp b/src/TDB2.cpp index 065f581d9..2c5ed1b4a 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -92,15 +92,8 @@ void TF2::target (const std::string& f) const std::vector & TF2::get_tasks () { if (! _loaded_tasks) - { load_tasks (); - // Apply previously added tasks. - std::vector ::iterator i; - for (i = _added_tasks.begin (); i != _added_tasks.end (); ++i) - _tasks.push_back (*i); - } - return _tasks; } @@ -108,15 +101,8 @@ const std::vector & TF2::get_tasks () const std::vector & TF2::get_lines () { if (! _loaded_lines) - { load_lines (); - // Apply previously added lines. - std::vector ::iterator i; - for (i = _added_lines.begin (); i != _added_lines.end (); ++i) - _lines.push_back (*i); - } - return _lines; } diff --git a/src/commands/CmdLog.cpp b/src/commands/CmdLog.cpp index a9c0a8883..70f7c0ae1 100644 --- a/src/commands/CmdLog.cpp +++ b/src/commands/CmdLog.cpp @@ -66,7 +66,6 @@ int CmdLog::execute (std::string& output) throw std::string (STRING_CMD_LOG_NO_WAITING); context.tdb2.add (task); - context.footnote (onProjectChange (task)); context.tdb2.commit (); diff --git a/test/bug.899.t b/test/bug.899.t new file mode 100755 index 000000000..edffd7c31 --- /dev/null +++ b/test/bug.899.t @@ -0,0 +1,65 @@ +#! /usr/bin/perl +################################################################################ +## taskwarrior - a command line task list manager. +## +## Copyright 2006-2012, Paul Beckingham, Federico Hernandez. +## +## Permission is hereby granted, free of charge, to any person obtaining a copy +## of this software and associated documentation files (the "Software"), to deal +## in the Software without restriction, including without limitation the rights +## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +## copies of the Software, and to permit persons to whom the Software is +## furnished to do so, subject to the following conditions: +## +## The above copyright notice and this permission notice shall be included +## in all copies or substantial portions of the Software. +## +## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +## SOFTWARE. +## +## http://www.opensource.org/licenses/mit-license.php +## +################################################################################ + +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=off\n"; + close $fh; + ok (-r 'bug.rc', 'Created bug.rc'); +} + +# Bug 899: task log does not behave correctly when logging into a project +my $output = qx{../src/task rc:bug.rc add one pro:A}; +like ($output, qr/ 0% complete \(1 of 1 /, '1 of 1 tasks remaining - 0%'); + +$output = qx{../src/task rc:bug.rc add two pro:A}; +like ($output, qr/ 0% complete \(2 of 2 /, '2 of 2 tasks remaining - 0%'); + +$output = qx{../src/task rc:bug.rc 1 done}; +like ($output, qr/ 50% complete \(1 of 2 /, '1 of 2 tasks remaining - 50%'); + +$output = qx{../src/task rc:bug.rc log three pro:A}; +like ($output, qr/ 66% complete \(1 of 3 /, '1 of 3 tasks remaining - 66%'); + +# Cleanup. +unlink qw(pending.data completed.data undo.data backlog.data synch.key bug.rc); +ok (! -r 'pending.data' && + ! -r 'completed.data' && + ! -r 'undo.data' && + ! -r 'backlog.data' && + ! -r 'synch.key' && + ! -r 'bug.rc', 'Cleanup'); + +exit 0; +