Skip to content
This repository has been archived by the owner on Mar 18, 2023. It is now read-only.

If a task does not have an HabitRPG id, then create a new task #36

Merged
merged 1 commit into from
Jan 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion habitSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ habitSync.prototype.syncItemsToHabitRpg = function(items, cb) {
task.attribute = attribute;
}

if(item.habitrpg) {
if(item.habitrpg && item.habitrpg.id) {
if(task.type == "todo") {
// Checks if the complete status has changed
if((task.completed != item.habitrpg.completed && item.habitrpg.completed !== undefined) ||
Expand Down
23 changes: 23 additions & 0 deletions test/todoist-habitrpg.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,29 @@ describe('todoist-habitrpg', function (done) {
});
});

it('should recreate a task if it has habitrpg history, but not habitrpg id', function(done) {
var modifiedTodoistResp = _.cloneDeep(todoistResponse);
modifiedTodoistResp.Items[0].content = "Getting there";
readHistoryFromFileStub.returns({
seqNo: todoistResponse.seq_no,
tasks: {
44444444: {
habitrpg: {attribute: 'str'},
todoist: todoistResponse.Items[0]
}
}
});
getTodoistSyncStub.callsArgWith(0, null, {body: modifiedTodoistResp});

sync.run(function() {
expect(syncItemsToHabitRpgSpy).to.have.been.calledWith([{habitrpg: {attribute: 'str'}, todoist: modifiedTodoistResp.Items[0]}]);
expect(habitapiStub.updateTask).to.not.have.been.called;
expect(habitapiStub.createTask).to.have.been.called;
expect(writeFileSyncStub).to.have.been.called;
done();
});
});

it('should process tasks without a date string', function(done) {
var modifiedTodoistResp = _.cloneDeep(todoistResponse);
modifiedTodoistResp.Items[0].due_date_utc = "Sat 06 Sep 2014 05:59:59 +0000";
Expand Down