mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-01 18:27:20 +02:00
Unit Tests
- While fixing bug.360.t, discovered a bigger problem, which is not yet fixed. When a due date is removed from a recurring child task, the imask, parent and recur attributes should also be removed. Similarly when a recur frequency is removed from a recurring child task, the imask and parent should also be removed. - Net result: two new failing tests.
This commit is contained in:
parent
02047a6e99
commit
d1e52c05d6
3 changed files with 28 additions and 31 deletions
|
@ -1795,7 +1795,6 @@ bool A3::extract_attr (
|
||||||
{
|
{
|
||||||
Nibbler n (input);
|
Nibbler n (input);
|
||||||
|
|
||||||
// Ensure a clean parse.
|
|
||||||
name = "";
|
name = "";
|
||||||
value = "";
|
value = "";
|
||||||
|
|
||||||
|
@ -1803,8 +1802,6 @@ bool A3::extract_attr (
|
||||||
{
|
{
|
||||||
if (n.skip (':'))
|
if (n.skip (':'))
|
||||||
{
|
{
|
||||||
// Both quoted and unquoted Att's are accepted.
|
|
||||||
// Consider removing this for a stricter parse.
|
|
||||||
if (n.getQuoted ('"', value) ||
|
if (n.getQuoted ('"', value) ||
|
||||||
n.getQuoted ('\'', value) ||
|
n.getQuoted ('\'', value) ||
|
||||||
n.getUntilEOS (value))
|
n.getUntilEOS (value))
|
||||||
|
@ -1828,7 +1825,6 @@ bool A3::extract_attmod (
|
||||||
{
|
{
|
||||||
Nibbler n (input);
|
Nibbler n (input);
|
||||||
|
|
||||||
// Ensure a clean parse.
|
|
||||||
name = "";
|
name = "";
|
||||||
value = "";
|
value = "";
|
||||||
modifier = "";
|
modifier = "";
|
||||||
|
@ -1847,8 +1843,6 @@ bool A3::extract_attmod (
|
||||||
if (n.skip (':') ||
|
if (n.skip (':') ||
|
||||||
n.skip ('='))
|
n.skip ('='))
|
||||||
{
|
{
|
||||||
// Both quoted and unquoted Att's are accepted.
|
|
||||||
// Consider removing this for a stricter parse.
|
|
||||||
if (n.getQuoted ('"', value) ||
|
if (n.getQuoted ('"', value) ||
|
||||||
n.getQuoted ('\'', value) ||
|
n.getQuoted ('\'', value) ||
|
||||||
n.getUntilEOS (value))
|
n.getUntilEOS (value))
|
||||||
|
|
|
@ -78,37 +78,38 @@ int CmdModify::execute (std::string& output)
|
||||||
Task before (*task);
|
Task before (*task);
|
||||||
modify_task_description_replace (*task, modifications);
|
modify_task_description_replace (*task, modifications);
|
||||||
|
|
||||||
|
// Perform some logical consistency checks.
|
||||||
|
if (task->has ("recur") &&
|
||||||
|
!task->has ("due") &&
|
||||||
|
!before.has ("due"))
|
||||||
|
throw std::string ("You cannot specify a recurring task without a due date.");
|
||||||
|
|
||||||
|
if (task->has ("until") &&
|
||||||
|
!task->has ("recur") &&
|
||||||
|
!before.has ("recur"))
|
||||||
|
throw std::string ("You cannot specify an until date for a non-recurring task.");
|
||||||
|
|
||||||
|
if (before.has ("recur") &&
|
||||||
|
before.has ("due") &&
|
||||||
|
(!task->has ("due") ||
|
||||||
|
task->get ("due") == ""))
|
||||||
|
throw std::string ("You cannot remove the due date from a recurring task.");
|
||||||
|
|
||||||
|
if (before.has ("recur") &&
|
||||||
|
task->has ("recur") &&
|
||||||
|
(!task->has ("recur") ||
|
||||||
|
task->get ("recur") == ""))
|
||||||
|
throw std::string ("You cannot remove the recurrence from a recurring task.");
|
||||||
|
|
||||||
if (taskDiff (before, *task) &&
|
if (taskDiff (before, *task) &&
|
||||||
permission.confirmed (*task, taskDifferences (before, *task) + "Proceed with change?"))
|
permission.confirmed (*task, taskDifferences (before, *task) + "Proceed with change?"))
|
||||||
{
|
{
|
||||||
|
// Checks passed, modify the task.
|
||||||
++count;
|
++count;
|
||||||
context.tdb2.modify (*task);
|
context.tdb2.modify (*task);
|
||||||
if (before.get ("project") != task->get ("project"))
|
if (before.get ("project") != task->get ("project"))
|
||||||
context.footnote (onProjectChange (before, *task));
|
context.footnote (onProjectChange (before, *task));
|
||||||
|
|
||||||
// Perform some logical consistency checks.
|
|
||||||
// TODO Shouldn't these tests be in Task::validate?
|
|
||||||
if (task->has ("recur") &&
|
|
||||||
!task->has ("due") &&
|
|
||||||
!before.has ("due"))
|
|
||||||
throw std::string ("You cannot specify a recurring task without a due date.");
|
|
||||||
|
|
||||||
if (task->has ("until") &&
|
|
||||||
!task->has ("recur") &&
|
|
||||||
!before.has ("recur"))
|
|
||||||
throw std::string ("You cannot specify an until date for a non-recurring task.");
|
|
||||||
|
|
||||||
if (before.has ("recur") &&
|
|
||||||
before.has ("due") &&
|
|
||||||
task->has ("due") &&
|
|
||||||
task->get ("due") == "")
|
|
||||||
throw std::string ("You cannot remove the due date from a recurring task.");
|
|
||||||
|
|
||||||
if (before.has ("recur") &&
|
|
||||||
task->has ("recur") &&
|
|
||||||
task->get ("recur") == "")
|
|
||||||
throw std::string ("You cannot remove the recurrence from a recurring task.");
|
|
||||||
|
|
||||||
// Make all changes.
|
// Make all changes.
|
||||||
bool warned = false;
|
bool warned = false;
|
||||||
std::vector <Task> siblings = context.tdb2.siblings (*task);
|
std::vector <Task> siblings = context.tdb2.siblings (*task);
|
||||||
|
|
|
@ -50,11 +50,13 @@ unlike ($output, qr/You cannot remove the recurrence from a recurring task./ms,
|
||||||
|
|
||||||
# Now try to generate the error above via regular means - ie, is it actually
|
# Now try to generate the error above via regular means - ie, is it actually
|
||||||
# doing what it should?
|
# doing what it should?
|
||||||
$output = qx{../src/task rc:bug.rc 1 modify recur:};
|
# TODO Removing recur: from a recurring task should also remove imask and parent.
|
||||||
|
$output = qx{../src/task rc:bug.rc 2 modify recur:};
|
||||||
like ($output, qr/You cannot remove the recurrence from a recurring task./ms, 'Recurrence removal error');
|
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.
|
# Prevent removal of the due date from a recurring task.
|
||||||
$output = qx{../src/task rc:bug.rc 1 modify due:};
|
# TODO Removing due: from a recurring task should also remove recur, imask and parent
|
||||||
|
$output = qx{../src/task rc:bug.rc 2 modify due:};
|
||||||
like ($output, qr/You cannot remove the due date from a recurring task./ms, 'Cannot remove due date from a recurring task');
|
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.
|
# Allow removal of the due date from a non-recurring task.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue