- Fixed bug #1023, which applied default.project and default.priority during
  modification (thanks to Christoph Lange).
- Added unit tests.
- Added Christoph to the AUTHORS file.
This commit is contained in:
Paul Beckingham
2012-07-04 16:44:16 -04:00
parent d16f434899
commit b0b8bfe1d2
6 changed files with 80 additions and 6 deletions

View File

@@ -477,7 +477,7 @@ void TDB2::add (Task& task)
void TDB2::modify (Task& task)
{
// Ensure the task is consistent, and provide defaults if necessary.
task.validate ();
task.validate (false);
// Find task, overwrite it.
Task original;

View File

@@ -1066,7 +1066,7 @@ void Task::substitute (
// 2) To provide suitable warnings about odd states
// 3) To generate errors when the inconsistencies are not fixable
//
void Task::validate ()
void Task::validate (bool applyDefault /* = true */)
{
Task::status status = getStatus ();
@@ -1105,7 +1105,7 @@ void Task::validate ()
setEnd ();
// Override with default.project, if not specified.
if (! has ("project"))
if (applyDefault && ! has ("project"))
{
std::string defaultProject = context.config.get ("default.project");
if (defaultProject != "" &&
@@ -1114,7 +1114,7 @@ void Task::validate ()
}
// Override with default.priority, if not specified.
if (get ("priority") == "")
if (applyDefault && get ("priority") == "")
{
std::string defaultPriority = context.config.get ("default.priority");
if (defaultPriority != "" &&
@@ -1123,7 +1123,7 @@ void Task::validate ()
}
// Override with default.due, if not specified.
if (get ("due") == "")
if (applyDefault && get ("due") == "")
{
std::string defaultDue = context.config.get ("default.due");
if (defaultDue != "" &&

View File

@@ -102,7 +102,7 @@ public:
void substitute (const std::string&, const std::string&, bool);
void validate ();
void validate (bool applyDefault = true);
float urgency_c () const;
float urgency ();