@dhyasama/totem-models 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.npmignore +14 -0
- package/changeBSON.js +27 -0
- package/dictionaries/nicknames.json +703 -0
- package/index.js +42 -0
- package/lib/Account.js +312 -0
- package/lib/Activity.js +138 -0
- package/lib/CalendarEvent.js +150 -0
- package/lib/Document.js +357 -0
- package/lib/Fund.js +143 -0
- package/lib/LimitedPartner.js +780 -0
- package/lib/List.js +217 -0
- package/lib/News.js +161 -0
- package/lib/Note.js +170 -0
- package/lib/Organization.js +1011 -0
- package/lib/Person.js +1163 -0
- package/package.json +37 -0
- package/test/Account.js +139 -0
- package/test/Activity.js +167 -0
- package/test/CalendarEvent.js +59 -0
- package/test/Fund.js +113 -0
- package/test/LimitedPartner.js +554 -0
- package/test/List.js +270 -0
- package/test/News.js +109 -0
- package/test/Note.js +304 -0
- package/test/Organization.js +750 -0
- package/test/Person.js +1042 -0
- package/test/config.js +49 -0
package/test/List.js
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var
|
|
4
|
+
|
|
5
|
+
should = require("should"),
|
|
6
|
+
config = require('./config')['test'],
|
|
7
|
+
_ = require('underscore'),
|
|
8
|
+
mongoose = require('mongoose'),
|
|
9
|
+
clearDB = require('mocha-mongoose')(config.db.uri, {noClear: true}),
|
|
10
|
+
LimitedPartner = mongoose.model('LimitedPartner'),
|
|
11
|
+
List = mongoose.model('List'),
|
|
12
|
+
Organization = mongoose.model('Organization'),
|
|
13
|
+
Person = mongoose.model('Person');
|
|
14
|
+
|
|
15
|
+
var lp, org, person, creator;
|
|
16
|
+
var myAwesomeList;
|
|
17
|
+
var secondCustomerId = new mongoose.Types.ObjectId();
|
|
18
|
+
var secondCustomerList;
|
|
19
|
+
|
|
20
|
+
describe('List', function() {
|
|
21
|
+
|
|
22
|
+
before(function(done) {
|
|
23
|
+
if (mongoose.connection.db) return done();
|
|
24
|
+
mongoose.connect(config.db.uri, done);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
before(function(done) {
|
|
28
|
+
clearDB(done);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
before(function(done) {
|
|
32
|
+
|
|
33
|
+
lp = new LimitedPartner();
|
|
34
|
+
lp.name = 'Big LP';
|
|
35
|
+
lp.slug = 'big-lp';
|
|
36
|
+
|
|
37
|
+
LimitedPartner.upsert(lp, 'test', 'lp-full', function(err, result) {
|
|
38
|
+
|
|
39
|
+
should.not.exist(err);
|
|
40
|
+
should.exist(result);
|
|
41
|
+
lp = result;
|
|
42
|
+
|
|
43
|
+
return done();
|
|
44
|
+
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
before(function(done) {
|
|
50
|
+
|
|
51
|
+
org = new Organization();
|
|
52
|
+
org.name = 'Big Org';
|
|
53
|
+
org.slug = 'big-org';
|
|
54
|
+
|
|
55
|
+
Organization.upsert(org, 'test', function(err, result) {
|
|
56
|
+
|
|
57
|
+
should.not.exist(err);
|
|
58
|
+
should.exist(result);
|
|
59
|
+
org = result;
|
|
60
|
+
|
|
61
|
+
return done();
|
|
62
|
+
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
before(function(done) {
|
|
68
|
+
|
|
69
|
+
person = new Person();
|
|
70
|
+
person.name = {
|
|
71
|
+
'first': 'Big',
|
|
72
|
+
'last': 'Person'
|
|
73
|
+
};
|
|
74
|
+
person.slug = 'big-person';
|
|
75
|
+
|
|
76
|
+
Person.upsert(person, 'test', function(err, result) {
|
|
77
|
+
|
|
78
|
+
should.not.exist(err);
|
|
79
|
+
should.exist(result);
|
|
80
|
+
person = result;
|
|
81
|
+
|
|
82
|
+
return done();
|
|
83
|
+
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
before(function(done) {
|
|
89
|
+
|
|
90
|
+
creator = new Person();
|
|
91
|
+
creator.name = {
|
|
92
|
+
'first': 'John',
|
|
93
|
+
'last': 'Lennon'
|
|
94
|
+
};
|
|
95
|
+
creator.slug = 'john-lennon';
|
|
96
|
+
creator.avatarUrl = 'https:/someawesomepic.com';
|
|
97
|
+
|
|
98
|
+
Person.upsert(creator, 'test', function(err, result) {
|
|
99
|
+
|
|
100
|
+
should.not.exist(err);
|
|
101
|
+
should.exist(result);
|
|
102
|
+
creator = result;
|
|
103
|
+
|
|
104
|
+
return done();
|
|
105
|
+
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('creates an empty list', function(done) {
|
|
111
|
+
|
|
112
|
+
List.createList('My Awesome List', {}, creator, function(err, result) {
|
|
113
|
+
should.not.exist(err);
|
|
114
|
+
should.exist(result);
|
|
115
|
+
myAwesomeList = result;
|
|
116
|
+
myAwesomeList.toJSON().toString().length.should.be.above(0);
|
|
117
|
+
return done();
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('creates an empty list for another customer', function(done) {
|
|
123
|
+
|
|
124
|
+
var previousCustomerId = config.CUSTOMER_ID;
|
|
125
|
+
config.CUSTOMER_ID = secondCustomerId;
|
|
126
|
+
|
|
127
|
+
List.createList('All the News', {}, creator, function(err, result) {
|
|
128
|
+
|
|
129
|
+
should.not.exist(err);
|
|
130
|
+
should.exist(result);
|
|
131
|
+
|
|
132
|
+
secondCustomerList = result;
|
|
133
|
+
secondCustomerList.toJSON().toString().length.should.be.above(0);
|
|
134
|
+
|
|
135
|
+
// Restore original value
|
|
136
|
+
config.CUSTOMER_ID = previousCustomerId;
|
|
137
|
+
|
|
138
|
+
return done();
|
|
139
|
+
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('adds an lp', function(done) {
|
|
145
|
+
List.addItem(myAwesomeList.id, lp.id, 'limitedPartners', function(err, result) {
|
|
146
|
+
should.not.exist(err);
|
|
147
|
+
should.exist(result);
|
|
148
|
+
result.limitedPartners.length.should.equal(1);
|
|
149
|
+
myAwesomeList = result;
|
|
150
|
+
myAwesomeList.toJSON().toString().length.should.be.above(0);
|
|
151
|
+
return done();
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('adds an organization', function(done) {
|
|
156
|
+
List.addItem(myAwesomeList.id, org.id, 'organizations', function(err, result) {
|
|
157
|
+
should.not.exist(err);
|
|
158
|
+
should.exist(result);
|
|
159
|
+
result.organizations.length.should.equal(1);
|
|
160
|
+
myAwesomeList = result;
|
|
161
|
+
myAwesomeList.toJSON().toString().length.should.be.above(0);
|
|
162
|
+
return done();
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it('adds a person', function(done) {
|
|
167
|
+
List.addItem(myAwesomeList.id, person.id, 'people', function(err, result) {
|
|
168
|
+
should.not.exist(err);
|
|
169
|
+
should.exist(result);
|
|
170
|
+
result.people.length.should.equal(1);
|
|
171
|
+
myAwesomeList = result;
|
|
172
|
+
myAwesomeList.toJSON().toString().length.should.be.above(0);
|
|
173
|
+
return done();
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('adds a person again and dedupes', function(done) {
|
|
178
|
+
List.addItem(myAwesomeList.id, person.id, 'people', function(err, result) {
|
|
179
|
+
should.not.exist(err);
|
|
180
|
+
should.exist(result);
|
|
181
|
+
result.people.length.should.equal(1);
|
|
182
|
+
myAwesomeList = result;
|
|
183
|
+
myAwesomeList.toJSON().toString().length.should.be.above(0);
|
|
184
|
+
return done();
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('removes an lp', function(done) {
|
|
189
|
+
List.removeItem(myAwesomeList.id, myAwesomeList.limitedPartners[0], 'limitedPartners', function(err, result) {
|
|
190
|
+
should.not.exist(err);
|
|
191
|
+
should.exist(result);
|
|
192
|
+
result.limitedPartners.length.should.equal(0);
|
|
193
|
+
myAwesomeList = result;
|
|
194
|
+
myAwesomeList.toJSON().toString().length.should.be.above(0);
|
|
195
|
+
return done();
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('gets a list by id', function(done) {
|
|
200
|
+
List.getById(myAwesomeList.id, function(err, result) {
|
|
201
|
+
|
|
202
|
+
should.not.exist(err);
|
|
203
|
+
should.exist(result);
|
|
204
|
+
result.id.should.equal(myAwesomeList.id);
|
|
205
|
+
should.exist(result.createdBy);
|
|
206
|
+
should.exist(result.createdBy.avatarUrl);
|
|
207
|
+
result.createdBy.avatarUrl.length.should.be.above(0);
|
|
208
|
+
should.exist(result.createdBy.name);
|
|
209
|
+
should.exist(result.createdBy.name.first);
|
|
210
|
+
result.createdBy.name.first.length.should.be.above(0);
|
|
211
|
+
|
|
212
|
+
myAwesomeList = result;
|
|
213
|
+
|
|
214
|
+
return done();
|
|
215
|
+
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it('tries to get a list belonging to a different customer', function(done) {
|
|
220
|
+
List.getById(secondCustomerList.id, function(err, result) {
|
|
221
|
+
should.not.exist(err);
|
|
222
|
+
should.not.exist(result);
|
|
223
|
+
return done();
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it('aggregates items in a list', function(done) {
|
|
228
|
+
List.getById(myAwesomeList.id, function(err, result) {
|
|
229
|
+
|
|
230
|
+
should.not.exist(err);
|
|
231
|
+
should.exist(result);
|
|
232
|
+
|
|
233
|
+
var itemCount = result.limitedPartners.length;
|
|
234
|
+
itemCount += result.organizations.length;
|
|
235
|
+
itemCount += result.people.length;
|
|
236
|
+
|
|
237
|
+
var aggregatedItems = myAwesomeList.items;
|
|
238
|
+
|
|
239
|
+
aggregatedItems.length.should.equal(itemCount);
|
|
240
|
+
|
|
241
|
+
return done();
|
|
242
|
+
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it('gets all lists for a customer', function(done) {
|
|
247
|
+
List.getLists(function(err, result) {
|
|
248
|
+
should.not.exist(err);
|
|
249
|
+
should.exist(result);
|
|
250
|
+
result.length.should.equal(1);
|
|
251
|
+
return done();
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
it('deletes a list', function(done) {
|
|
257
|
+
|
|
258
|
+
List.remove(myAwesomeList.id, function(err, result) {
|
|
259
|
+
|
|
260
|
+
should.not.exist(err);
|
|
261
|
+
should.exist(result);
|
|
262
|
+
result.id.should.equal(myAwesomeList.id);
|
|
263
|
+
|
|
264
|
+
return done();
|
|
265
|
+
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
});
|
package/test/News.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var
|
|
4
|
+
|
|
5
|
+
should = require("should"),
|
|
6
|
+
config = require('./config')['test'],
|
|
7
|
+
mongoose = require('mongoose'),
|
|
8
|
+
clearDB = require('mocha-mongoose')(config.db.uri, {noClear: true}),
|
|
9
|
+
News = mongoose.model('News'),
|
|
10
|
+
news = new News(),
|
|
11
|
+
//fund._id = new mongoose.Types.ObjectId();
|
|
12
|
+
Fund = mongoose.model('Fund'),
|
|
13
|
+
fund = new Fund();
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
describe('News', function() {
|
|
18
|
+
|
|
19
|
+
before(function(done) {
|
|
20
|
+
if (mongoose.connection.db) return done();
|
|
21
|
+
mongoose.connect(config.db.uri, done);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
before(function(done) {
|
|
25
|
+
clearDB(done);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('adds a news item', function(done) {
|
|
29
|
+
|
|
30
|
+
news.createdBy = 'Jason';
|
|
31
|
+
news.createdOn = Date.now();
|
|
32
|
+
news.title = 'Google';
|
|
33
|
+
news.link = 'http://google.com';
|
|
34
|
+
news.fundsInvolved.push(fund._id);
|
|
35
|
+
news.internal = false;
|
|
36
|
+
news.discourse.id = '1';
|
|
37
|
+
news.discourse.slug = 'google';
|
|
38
|
+
news.discourse.firstPostId = '1';
|
|
39
|
+
|
|
40
|
+
News.upsert(news, function(err, item) {
|
|
41
|
+
should.not.exist(err);
|
|
42
|
+
should.exist(item);
|
|
43
|
+
item.fundsInvolved.length.should.equal(1);
|
|
44
|
+
news = item;
|
|
45
|
+
done();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('updates a news item', function(done) {
|
|
51
|
+
|
|
52
|
+
news.excerpt = 'Amazing new search portal';
|
|
53
|
+
|
|
54
|
+
News.upsert(news, function(err, item) {
|
|
55
|
+
should.not.exist(err);
|
|
56
|
+
should.exist(item);
|
|
57
|
+
news = item;
|
|
58
|
+
done();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('gets a news item by id', function(done) {
|
|
64
|
+
News.getById(news.id, function(err, item) {
|
|
65
|
+
should.not.exist(err);
|
|
66
|
+
should.exist(item);
|
|
67
|
+
item.id.should.equal(news.id);
|
|
68
|
+
done();
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('lists all news items', function(done) {
|
|
73
|
+
News.list(function(err, items) {
|
|
74
|
+
should.not.exist(err);
|
|
75
|
+
should.exist(items);
|
|
76
|
+
items.length.should.equal(1);
|
|
77
|
+
done();
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('lists news items for a fund', function(done) {
|
|
82
|
+
News.listForFunds([fund._id], function(err, items) {
|
|
83
|
+
should.not.exist(err);
|
|
84
|
+
should.exist(items);
|
|
85
|
+
items.length.should.equal(1);
|
|
86
|
+
done();
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
it('lists news items for funds', function(done) {
|
|
92
|
+
News.listForFunds([fund._id, new mongoose.Types.ObjectId()], function(err, items) {
|
|
93
|
+
should.not.exist(err);
|
|
94
|
+
should.exist(items);
|
|
95
|
+
items.length.should.equal(1);
|
|
96
|
+
done();
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('deletes a news item', function(done) {
|
|
101
|
+
News.delete(news.id, function(err, item) {
|
|
102
|
+
should.not.exist(err);
|
|
103
|
+
done();
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// todo - listforcompany
|
|
108
|
+
|
|
109
|
+
});
|
package/test/Note.js
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var
|
|
4
|
+
|
|
5
|
+
should = require("should"),
|
|
6
|
+
config = require('./config')['test'],
|
|
7
|
+
_ = require('underscore'),
|
|
8
|
+
mongoose = require('mongoose'),
|
|
9
|
+
clearDB = require('mocha-mongoose')(config.db.uri, {noClear: true}),
|
|
10
|
+
LimitedPartner = mongoose.model('LimitedPartner'),
|
|
11
|
+
Note = mongoose.model('Note'),
|
|
12
|
+
Organization = mongoose.model('Organization'),
|
|
13
|
+
Person = mongoose.model('Person');
|
|
14
|
+
|
|
15
|
+
var lp, org, person, person2, person3, person4, noteCreator;
|
|
16
|
+
var accountId = new mongoose.Types.ObjectId();
|
|
17
|
+
var noteId, groupNoteId;
|
|
18
|
+
|
|
19
|
+
describe('Note', function() {
|
|
20
|
+
|
|
21
|
+
before(function(done) {
|
|
22
|
+
if (mongoose.connection.db) return done();
|
|
23
|
+
mongoose.connect(config.db.uri, done);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
before(function(done) {
|
|
27
|
+
clearDB(done);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
before(function(done) {
|
|
31
|
+
|
|
32
|
+
lp = new LimitedPartner();
|
|
33
|
+
lp.name = 'Big LP';
|
|
34
|
+
lp.slug = 'big-lp';
|
|
35
|
+
|
|
36
|
+
LimitedPartner.upsert(lp, 'test', 'lp-full', function(err, result) {
|
|
37
|
+
|
|
38
|
+
should.not.exist(err);
|
|
39
|
+
should.exist(result);
|
|
40
|
+
lp = result;
|
|
41
|
+
|
|
42
|
+
return done();
|
|
43
|
+
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
before(function(done) {
|
|
49
|
+
|
|
50
|
+
org = new Organization();
|
|
51
|
+
org.name = 'Big Org';
|
|
52
|
+
org.slug = 'big-org';
|
|
53
|
+
|
|
54
|
+
Organization.upsert(org, 'test', function(err, result) {
|
|
55
|
+
|
|
56
|
+
should.not.exist(err);
|
|
57
|
+
should.exist(result);
|
|
58
|
+
org = result;
|
|
59
|
+
|
|
60
|
+
return done();
|
|
61
|
+
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
before(function(done) {
|
|
67
|
+
|
|
68
|
+
person = new Person();
|
|
69
|
+
person.name = {
|
|
70
|
+
'first': 'Big',
|
|
71
|
+
'last': 'Person'
|
|
72
|
+
};
|
|
73
|
+
person.slug = 'big-person';
|
|
74
|
+
|
|
75
|
+
Person.upsert(person, 'test', function(err, result) {
|
|
76
|
+
|
|
77
|
+
should.not.exist(err);
|
|
78
|
+
should.exist(result);
|
|
79
|
+
person = result;
|
|
80
|
+
|
|
81
|
+
return done();
|
|
82
|
+
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
before(function(done) {
|
|
88
|
+
|
|
89
|
+
person2 = new Person();
|
|
90
|
+
person2.name = {
|
|
91
|
+
'first': 'Another',
|
|
92
|
+
'last': 'Girl'
|
|
93
|
+
};
|
|
94
|
+
person2.slug = 'another-girl';
|
|
95
|
+
|
|
96
|
+
Person.upsert(person2, 'test', function(err, result) {
|
|
97
|
+
|
|
98
|
+
should.not.exist(err);
|
|
99
|
+
should.exist(result);
|
|
100
|
+
person2 = result;
|
|
101
|
+
|
|
102
|
+
return done();
|
|
103
|
+
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
before(function(done) {
|
|
109
|
+
|
|
110
|
+
person3 = new Person();
|
|
111
|
+
person3.name = {
|
|
112
|
+
'first': 'Different',
|
|
113
|
+
'last': 'Guy'
|
|
114
|
+
};
|
|
115
|
+
person3.slug = 'different-guy';
|
|
116
|
+
|
|
117
|
+
Person.upsert(person3, 'test', function(err, result) {
|
|
118
|
+
|
|
119
|
+
should.not.exist(err);
|
|
120
|
+
should.exist(result);
|
|
121
|
+
person3 = result;
|
|
122
|
+
|
|
123
|
+
return done();
|
|
124
|
+
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
before(function(done) {
|
|
130
|
+
|
|
131
|
+
person4 = new Person();
|
|
132
|
+
person4.name = {
|
|
133
|
+
'first': 'Lady',
|
|
134
|
+
'last': 'Marmaduke'
|
|
135
|
+
};
|
|
136
|
+
person4.slug = 'lady-marmaduke';
|
|
137
|
+
|
|
138
|
+
Person.upsert(person4, 'test', function(err, result) {
|
|
139
|
+
|
|
140
|
+
should.not.exist(err);
|
|
141
|
+
should.exist(result);
|
|
142
|
+
person4 = result;
|
|
143
|
+
|
|
144
|
+
return done();
|
|
145
|
+
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
before(function(done) {
|
|
151
|
+
|
|
152
|
+
var eventSummary = {
|
|
153
|
+
calendarEventId: new mongoose.Types.ObjectId(),
|
|
154
|
+
providerEventId: 'some_other_random_data',
|
|
155
|
+
totemCustomerId: config.CUSTOMER_ID,
|
|
156
|
+
summary: 'The Russians are coming',
|
|
157
|
+
startTime: new Date(),
|
|
158
|
+
attendees: {
|
|
159
|
+
internal: [person._id],
|
|
160
|
+
external: [person2._id, person3._id]
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
person2.calendarEventSummaries.push(eventSummary);
|
|
165
|
+
person3.calendarEventSummaries.push(eventSummary);
|
|
166
|
+
|
|
167
|
+
Person.upsert(person2, 'test-user', function(err, result) {
|
|
168
|
+
|
|
169
|
+
should.not.exist(err);
|
|
170
|
+
should.exist(result);
|
|
171
|
+
person2 = result;
|
|
172
|
+
|
|
173
|
+
Person.upsert(person3, 'test-user', function(err, result) {
|
|
174
|
+
|
|
175
|
+
should.not.exist(err);
|
|
176
|
+
should.exist(result);
|
|
177
|
+
person3 = result;
|
|
178
|
+
|
|
179
|
+
return done();
|
|
180
|
+
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
before(function(done) {
|
|
188
|
+
|
|
189
|
+
noteCreator = new Person();
|
|
190
|
+
noteCreator.name = {
|
|
191
|
+
'first': 'George',
|
|
192
|
+
'last': 'Michael'
|
|
193
|
+
};
|
|
194
|
+
noteCreator.slug = 'george-michael';
|
|
195
|
+
|
|
196
|
+
Person.upsert(noteCreator, 'test', function(err, result) {
|
|
197
|
+
|
|
198
|
+
should.not.exist(err);
|
|
199
|
+
should.exist(result);
|
|
200
|
+
noteCreator = result;
|
|
201
|
+
|
|
202
|
+
return done();
|
|
203
|
+
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it('creates a note for an organization', function(done) {
|
|
209
|
+
|
|
210
|
+
Note.createForModel({
|
|
211
|
+
createdBy: noteCreator,
|
|
212
|
+
text: 'Best note ever!'
|
|
213
|
+
}, Organization, org._id, function(err, result) {
|
|
214
|
+
|
|
215
|
+
should.not.exist(err);
|
|
216
|
+
should.exist(result);
|
|
217
|
+
should.exist(result.note);
|
|
218
|
+
should.exist(result.addedTo);
|
|
219
|
+
result.addedTo.notes.length.should.equal(1);
|
|
220
|
+
|
|
221
|
+
noteId = result.addedTo.notes[0];
|
|
222
|
+
|
|
223
|
+
return done();
|
|
224
|
+
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it('creates a note for a limited partner', function(done) {
|
|
230
|
+
|
|
231
|
+
Note.createForModel({
|
|
232
|
+
createdBy: noteCreator,
|
|
233
|
+
text: 'Best note ever!'
|
|
234
|
+
}, LimitedPartner, lp._id, function(err, result) {
|
|
235
|
+
|
|
236
|
+
should.not.exist(err);
|
|
237
|
+
should.exist(result);
|
|
238
|
+
should.exist(result.note);
|
|
239
|
+
should.exist(result.addedTo);
|
|
240
|
+
result.addedTo.notes.length.should.equal(1);
|
|
241
|
+
|
|
242
|
+
return done();
|
|
243
|
+
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('creates a note for a person', function(done) {
|
|
249
|
+
|
|
250
|
+
Note.createForModel({
|
|
251
|
+
createdBy: noteCreator,
|
|
252
|
+
text: 'Best note ever!'
|
|
253
|
+
}, Person, person._id, function(err, result) {
|
|
254
|
+
|
|
255
|
+
should.not.exist(err);
|
|
256
|
+
should.exist(result);
|
|
257
|
+
should.exist(result.note);
|
|
258
|
+
should.exist(result.addedTo);
|
|
259
|
+
result.addedTo.notes.length.should.equal(1);
|
|
260
|
+
|
|
261
|
+
return done();
|
|
262
|
+
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
it('creates a note for an event', function(done) {
|
|
268
|
+
|
|
269
|
+
var providerEventId = 'some_other_random_data';
|
|
270
|
+
var creator = person._id;
|
|
271
|
+
var text = 'Sweet note bro!';
|
|
272
|
+
|
|
273
|
+
Note.createForCalendarEvent(providerEventId, creator, text, function(err, result) {
|
|
274
|
+
|
|
275
|
+
should.not.exist(err);
|
|
276
|
+
should.exist(result);
|
|
277
|
+
|
|
278
|
+
groupNoteId = result.id;
|
|
279
|
+
|
|
280
|
+
return done();
|
|
281
|
+
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
it('gets a note by id', function(done) {
|
|
287
|
+
Note.getById(noteId, function(err, result) {
|
|
288
|
+
should.not.exist(err);
|
|
289
|
+
should.exist(result);
|
|
290
|
+
result.text.should.equal('Best note ever!');
|
|
291
|
+
return done();
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
it('deletes a note', function(done) {
|
|
296
|
+
Note.delete(noteId, function(err, result) {
|
|
297
|
+
should.not.exist(err);
|
|
298
|
+
should.exist(result);
|
|
299
|
+
//result.id.should.equal(noteId.toString());
|
|
300
|
+
return done();
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
});
|