- Fixed bug in modify and append that was erroneously reporting "No
  changes" when a bulk update occurred.
- Added bug.bulk.t unit tests to cover this example.
This commit is contained in:
Paul Beckingham 2009-07-12 18:38:57 -04:00
parent b02c11be0e
commit e2da1d0a9a
2 changed files with 104 additions and 10 deletions

View file

@ -532,7 +532,8 @@ std::string handleDelete ()
std::vector <Task> tasks; std::vector <Task> tasks;
context.tdb.lock (context.config.get ("locking", true)); context.tdb.lock (context.config.get ("locking", true));
handleRecurrence (); handleRecurrence ();
context.tdb.loadPending (tasks, context.filter); Filter filter;
context.tdb.loadPending (tasks, filter);
// Filter sequence. // Filter sequence.
std::vector <Task> all = tasks; std::vector <Task> all = tasks;
@ -631,7 +632,8 @@ std::string handleStart ()
std::vector <Task> tasks; std::vector <Task> tasks;
context.tdb.lock (context.config.get ("locking", true)); context.tdb.lock (context.config.get ("locking", true));
handleRecurrence (); handleRecurrence ();
context.tdb.loadPending (tasks, context.filter); Filter filter;
context.tdb.loadPending (tasks, filter);
// Filter sequence. // Filter sequence.
context.filter.applySequence (tasks, context.sequence); context.filter.applySequence (tasks, context.sequence);
@ -682,7 +684,8 @@ std::string handleStop ()
std::vector <Task> tasks; std::vector <Task> tasks;
context.tdb.lock (context.config.get ("locking", true)); context.tdb.lock (context.config.get ("locking", true));
handleRecurrence (); handleRecurrence ();
context.tdb.loadPending (tasks, context.filter); Filter filter;
context.tdb.loadPending (tasks, filter);
// Filter sequence. // Filter sequence.
context.filter.applySequence (tasks, context.sequence); context.filter.applySequence (tasks, context.sequence);
@ -728,7 +731,8 @@ std::string handleDone ()
std::vector <Task> tasks; std::vector <Task> tasks;
context.tdb.lock (context.config.get ("locking", true)); context.tdb.lock (context.config.get ("locking", true));
handleRecurrence (); handleRecurrence ();
context.tdb.loadPending (tasks, context.filter); Filter filter;
context.tdb.loadPending (tasks, filter);
// Filter sequence. // Filter sequence.
std::vector <Task> all = tasks; std::vector <Task> all = tasks;
@ -858,7 +862,8 @@ std::string handleModify ()
std::vector <Task> tasks; std::vector <Task> tasks;
context.tdb.lock (context.config.get ("locking", true)); context.tdb.lock (context.config.get ("locking", true));
handleRecurrence (); handleRecurrence ();
context.tdb.loadPending (tasks, context.filter); Filter filter;
context.tdb.loadPending (tasks, filter);
// Filter sequence. // Filter sequence.
std::vector <Task> all = tasks; std::vector <Task> all = tasks;
@ -907,7 +912,7 @@ std::string handleModify ()
if (taskDiff (before, *other)) if (taskDiff (before, *other))
{ {
if (changes && permission.confirmed (before, taskDifferences (before, *task) + "Are you sure?")) if (changes && permission.confirmed (before, taskDifferences (before, *other) + "Are you sure?"))
{ {
context.tdb.update (*other); context.tdb.update (*other);
++count; ++count;
@ -935,7 +940,8 @@ std::string handleAppend ()
std::vector <Task> tasks; std::vector <Task> tasks;
context.tdb.lock (context.config.get ("locking", true)); context.tdb.lock (context.config.get ("locking", true));
handleRecurrence (); handleRecurrence ();
context.tdb.loadPending (tasks, context.filter); Filter filter;
context.tdb.loadPending (tasks, filter);
// Filter sequence. // Filter sequence.
std::vector <Task> all = tasks; std::vector <Task> all = tasks;
@ -966,7 +972,7 @@ std::string handleAppend ()
if (taskDiff (before, *other)) if (taskDiff (before, *other))
{ {
if (changes && permission.confirmed (before, taskDifferences (before, *task) + "Are you sure?")) if (changes && permission.confirmed (before, taskDifferences (before, *other) + "Are you sure?"))
{ {
context.tdb.update (*other); context.tdb.update (*other);
@ -1001,7 +1007,8 @@ std::string handleDuplicate ()
std::vector <Task> tasks; std::vector <Task> tasks;
context.tdb.lock (context.config.get ("locking", true)); context.tdb.lock (context.config.get ("locking", true));
context.tdb.loadPending (tasks, context.filter); Filter filter;
context.tdb.loadPending (tasks, filter);
// Filter sequence. // Filter sequence.
context.filter.applySequence (tasks, context.sequence); context.filter.applySequence (tasks, context.sequence);
@ -1235,7 +1242,8 @@ std::string handleAnnotate ()
std::vector <Task> tasks; std::vector <Task> tasks;
context.tdb.lock (context.config.get ("locking", true)); context.tdb.lock (context.config.get ("locking", true));
context.tdb.loadPending (tasks, context.filter); Filter filter;
context.tdb.loadPending (tasks, filter);
// Filter sequence. // Filter sequence.
context.filter.applySequence (tasks, context.sequence); context.filter.applySequence (tasks, context.sequence);

86
src/tests/bug.bulk.t Executable file
View file

@ -0,0 +1,86 @@
#! /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 => 14;
# Create the rc file.
if (open my $fh, '>', 'bulk.rc')
{
print $fh "data.location=.\n",
"confirmation=yes\n",
"bulk=2\n";
close $fh;
ok (-r 'bulk.rc', 'Created bulk.rc');
}
# Add some tasks with project, prioriy and due date, some with only due date.
# Bulk add a project and priority to the tasks that were without.
qx{../task rc:bulk.rc add t1 pro:p1 pri:H due:monday};
qx{../task rc:bulk.rc add t2 pro:p1 pri:M due:tuesday};
qx{../task rc:bulk.rc add t3 pro:p1 pri:L due:wednesday};
qx{../task rc:bulk.rc add t4 due:thursday};
qx{../task rc:bulk.rc add t5 due:friday};
qx{../task rc:bulk.rc add t6 due:saturday};
my $output = qx{yes|../task rc:bulk.rc pro:p1 pri:M 4 5 6};
unlike ($output, qr/Task 4 "t4"\n - No changes were made/, 'Task 4 modified');
unlike ($output, qr/Task 5 "t5"\n - No changes were made/, 'Task 5 modified');
unlike ($output, qr/Task 6 "t6"\n - No changes were made/, 'Task 6 modified');
#diag ("---");
#diag ($output);
#diag ("---");
$output = qx{../task rc:bulk.rc info 4};
like ($output, qr/Project\s+p1/, 'project applied to 4');
like ($output, qr/Priority\s+M/, 'priority applied to 4');
$output = qx{../task rc:bulk.rc info 5};
like ($output, qr/Project\s+p1/, 'project applied to 5');
like ($output, qr/Priority\s+M/, 'priority applied to 5');
$output = qx{../task rc:bulk.rc info 6};
like ($output, qr/Project\s+p1/, 'project applied to 6');
like ($output, qr/Priority\s+M/, 'priority applied to 6');
# 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 'bulk.rc';
ok (!-r 'bulk.rc', 'Removed bulk.rc');
exit 0;