add project behind the scenes if it doesn't exist; #116

This commit is contained in:
Radek Stepan 2016-03-24 21:36:24 -04:00
parent 9460c981fd
commit d8730c3c2d
3 changed files with 192 additions and 13 deletions

File diff suppressed because one or more lines are too long

View File

@ -64,9 +64,6 @@ class ProjectsStore extends Store {
onProjectsLoad(args) {
let projects = this.get('list');
// Quit if we have no projects.
if (!projects.length) return;
// Wait for the user to get resolved.
this.get('user', this.cb((user) => { // async
if (args) {
@ -343,8 +340,10 @@ class ProjectsStore extends Store {
// Notify?
if (say) this.notify(milestone);
// We are supposed to exist already.
if ((i = this.findIndex(project)) < 0) { throw 500; }
// If project hasn't been found, add it behind the scenes.
if ((i = this.findIndex(project)) < 0) {
i = this.push('list', project);
}
// Does the milestone exist already?
let milestones;

View File

@ -1,5 +1,6 @@
import { assert } from 'chai';
import path from 'path';
import _ from 'lodash';
import { noCallThru } from 'proxyquire'
let proxy = noCallThru();
@ -261,6 +262,25 @@ export default {
assert.deepEqual(projects.get('list'), [ a, c ]);
assert.deepEqual(projects.get('index'), [ [ 0, 0 ], [ 1, 0 ] ]);
done();
},
// Issue #116.
'projects - add milestone (project behind the scenes)': (done) => {
projects.set({ 'list': [], 'index': [], 'sortBy': 'progress' });
let p = { 'name': 'zcash', 'owner': 'zcash' };
let m = { 'issues': {
'closed': { 'list': [], 'size': 0 },
'open': { 'list': [], 'size': 0 }
}};
projects.addMilestone(p, m);
assert.deepEqual(projects.get('list'), [
_.extend(p, { 'milestones': [ m ] })
]);
done();
}
};