@dhyasama/totem-models 7.57.0 → 8.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/helpers.js +89 -0
- package/index.js +0 -1
- package/lib/Account.js +125 -79
- package/lib/Activity.js +0 -2
- package/lib/CalendarEvent.js +1 -7
- package/lib/CapTable.js +0 -1
- package/lib/Deal.js +215 -151
- package/lib/Document.js +57 -56
- package/lib/Financials.js +115 -172
- package/lib/Flag.js +37 -14
- package/lib/Fund.js +6 -33
- package/lib/Interaction.js +79 -32
- package/lib/Investment.js +4 -10
- package/lib/LimitedPartner.js +303 -634
- package/lib/List.js +105 -147
- package/lib/Message.js +100 -51
- package/lib/News.js +1 -53
- package/lib/Note.js +60 -66
- package/lib/Organization.js +470 -645
- package/lib/Person.js +342 -650
- package/lib/Round.js +191 -134
- package/lib/Snapshot.js +3 -5
- package/lib/Webhook.js +1 -4
- package/package-lock.json +1927 -0
- package/package.json +2 -3
- package/test/Account.js +53 -38
- package/test/Deal.js +14 -30
- package/test/Document.js +51 -50
- package/test/Financials.js +5 -3
- package/test/Flag.js +18 -14
- package/test/Interaction.js +1 -31
- package/test/Investment.js +2 -3
- package/test/LimitedPartner.js +399 -554
- package/test/List.js +24 -29
- package/test/Message.js +7 -46
- package/test/News.js +12 -29
- package/test/Note.js +23 -22
- package/test/Organization.js +33 -307
- package/test/Person.js +6 -253
- package/test/Round.js +11 -11
- package/lib/Sync.js +0 -48
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhyasama/totem-models",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"author": "Jason Reynolds",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"description": "Models for Totem platform",
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
"moment": "^2.24.0",
|
|
24
24
|
"mongoose-deep-populate": "^3.0.0",
|
|
25
25
|
"mongoose-filter-denormalize": "^0.2.1",
|
|
26
|
-
"mongoose-post-find": "0.0.2",
|
|
27
26
|
"phone-formatter": "0.0.2",
|
|
28
27
|
"underscore": "~1.5.0",
|
|
29
28
|
"validator": "^5.4.0"
|
|
@@ -31,7 +30,7 @@
|
|
|
31
30
|
"devDependencies": {
|
|
32
31
|
"mocha": "^5.2.0",
|
|
33
32
|
"mocha-mongoose": "^1.2.0",
|
|
34
|
-
"mongoose": "~4.
|
|
33
|
+
"mongoose": "~4.5.7",
|
|
35
34
|
"nock": "^7.2.2",
|
|
36
35
|
"rewire": "^3.0.2",
|
|
37
36
|
"should": "^11.1.1"
|
package/test/Account.js
CHANGED
|
@@ -7,15 +7,13 @@ var
|
|
|
7
7
|
mongoose = require('mongoose'),
|
|
8
8
|
models = require('../index')(mongoose, config),
|
|
9
9
|
clearDB = require('mocha-mongoose')(config.db.uri, {noClear: true}),
|
|
10
|
-
Crypto = require('@dhyasama/ffvc-crypto'),
|
|
11
|
-
crypto = new Crypto({'key': config.crypto.key}),
|
|
12
10
|
Account = mongoose.model('Account'),
|
|
13
11
|
Organization = mongoose.model('Organization'),
|
|
14
12
|
Person = mongoose.model('Person'),
|
|
15
13
|
person = new Person();
|
|
16
14
|
|
|
17
15
|
var accountid;
|
|
18
|
-
var
|
|
16
|
+
var customer1, customer2;
|
|
19
17
|
|
|
20
18
|
describe('Account', function() {
|
|
21
19
|
|
|
@@ -30,16 +28,31 @@ describe('Account', function() {
|
|
|
30
28
|
|
|
31
29
|
before(function(done) {
|
|
32
30
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
customer1 = new Organization();
|
|
32
|
+
customer1.name = 'Fudgesicle';
|
|
33
|
+
customer1.slug = 'fudgesicle';
|
|
34
|
+
customer1.website = 'yum.io';
|
|
35
|
+
customer1.deleted = false;
|
|
36
|
+
customer1.aliases.push('sicle');
|
|
37
|
+
customer1.crunchbase.uuid = 'jkl';
|
|
38
|
+
customer1.crunchbase.url = 'jkl';
|
|
41
39
|
|
|
42
|
-
Organization.upsert(
|
|
40
|
+
Organization.upsert(customer1, 'test-user', function (err, no5) {
|
|
41
|
+
done();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
before(function(done) {
|
|
47
|
+
|
|
48
|
+
customer2 = new Organization();
|
|
49
|
+
customer2.name = 'Creamsicle';
|
|
50
|
+
customer2.slug = 'Creamsicle';
|
|
51
|
+
customer2.website = 'superyum.io';
|
|
52
|
+
customer2.deleted = false;
|
|
53
|
+
customer2.aliases.push('Cream');
|
|
54
|
+
|
|
55
|
+
Organization.upsert(customer2, 'test-user', function (err, no5) {
|
|
43
56
|
done();
|
|
44
57
|
});
|
|
45
58
|
|
|
@@ -55,48 +68,49 @@ describe('Account', function() {
|
|
|
55
68
|
should.not.exist(err);
|
|
56
69
|
should.exist(newPerson);
|
|
57
70
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
should.not.exist(err);
|
|
61
|
-
should.exist(hash);
|
|
62
|
-
|
|
63
|
-
var account = new Account();
|
|
71
|
+
var account = new Account();
|
|
64
72
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
Account.upsert(account, function(err, updatedAccount) {
|
|
72
|
-
should.not.exist(err);
|
|
73
|
-
should.exist(updatedAccount);
|
|
74
|
-
accountid = updatedAccount.id;
|
|
75
|
-
done();
|
|
76
|
-
});
|
|
73
|
+
account.username = 'testy';
|
|
74
|
+
account.email = 'test@totemvc.com';
|
|
75
|
+
account.person = newPerson;
|
|
76
|
+
account.active = true;
|
|
77
|
+
account.org = customer1;
|
|
77
78
|
|
|
79
|
+
Account.upsert(account, function(err, updatedAccount) {
|
|
80
|
+
should.not.exist(err);
|
|
81
|
+
should.exist(updatedAccount);
|
|
82
|
+
accountid = updatedAccount.id;
|
|
83
|
+
done();
|
|
78
84
|
});
|
|
79
85
|
|
|
80
86
|
});
|
|
81
87
|
|
|
82
88
|
});
|
|
83
89
|
|
|
84
|
-
it('
|
|
90
|
+
it('creates another account', function(done) {
|
|
85
91
|
|
|
86
|
-
Account
|
|
92
|
+
var account = new Account();
|
|
93
|
+
|
|
94
|
+
account.username = 'tipsy';
|
|
95
|
+
account.email = 'tipsy@totemvc.com';
|
|
96
|
+
account.person = person;
|
|
97
|
+
account.active = true;
|
|
98
|
+
account.org = customer2;
|
|
99
|
+
|
|
100
|
+
Account.upsert(account, function(err, updatedAccount) {
|
|
87
101
|
should.not.exist(err);
|
|
88
|
-
should.exist(
|
|
89
|
-
account.id.should.equal(accountid);
|
|
102
|
+
should.exist(updatedAccount);
|
|
90
103
|
done();
|
|
91
104
|
});
|
|
92
105
|
|
|
93
106
|
});
|
|
94
107
|
|
|
95
|
-
it('finds by
|
|
108
|
+
it('finds by id', function(done) {
|
|
96
109
|
|
|
97
|
-
Account.
|
|
110
|
+
Account.getById(accountid, function(err, account) {
|
|
98
111
|
should.not.exist(err);
|
|
99
112
|
should.exist(account);
|
|
113
|
+
account.id.should.equal(accountid);
|
|
100
114
|
done();
|
|
101
115
|
});
|
|
102
116
|
|
|
@@ -124,7 +138,7 @@ describe('Account', function() {
|
|
|
124
138
|
|
|
125
139
|
it('lists all active accounts', function(done) {
|
|
126
140
|
|
|
127
|
-
Account.listAllAccounts(function(err, result) {
|
|
141
|
+
Account.listAllAccounts({ isWorkerProcess: false }, function(err, result) {
|
|
128
142
|
should.not.exist(err);
|
|
129
143
|
should.exist(result);
|
|
130
144
|
done();
|
|
@@ -134,9 +148,10 @@ describe('Account', function() {
|
|
|
134
148
|
|
|
135
149
|
it('lists accounts for customer', function(done) {
|
|
136
150
|
|
|
137
|
-
Account.getForCustomer(
|
|
151
|
+
Account.getForCustomer(customer1._id, function(err, result) {
|
|
138
152
|
should.not.exist(err);
|
|
139
153
|
should.exist(result);
|
|
154
|
+
result.length.should.equal(1);
|
|
140
155
|
done();
|
|
141
156
|
});
|
|
142
157
|
|
package/test/Deal.js
CHANGED
|
@@ -60,8 +60,6 @@ describe('Deal', function() {
|
|
|
60
60
|
|
|
61
61
|
customer = result;
|
|
62
62
|
|
|
63
|
-
config.CUSTOMER_ID = customer._id.toString();
|
|
64
|
-
|
|
65
63
|
return done();
|
|
66
64
|
|
|
67
65
|
});
|
|
@@ -74,6 +72,7 @@ describe('Deal', function() {
|
|
|
74
72
|
account.username = 'test-user';
|
|
75
73
|
account.email = 'test@totemvc.com';
|
|
76
74
|
account.person = new mongoose.Types.ObjectId();
|
|
75
|
+
account.org = customer._id;
|
|
77
76
|
|
|
78
77
|
Account.upsert(account, function (err, result) {
|
|
79
78
|
|
|
@@ -102,7 +101,7 @@ describe('Deal', function() {
|
|
|
102
101
|
}
|
|
103
102
|
});
|
|
104
103
|
|
|
105
|
-
Deal.upsert(deal, account, function(err, result) {
|
|
104
|
+
Deal.upsert(deal, { account: account, CUSTOMER_ID: customer._id }, function(err, result) {
|
|
106
105
|
|
|
107
106
|
should.not.exist(err);
|
|
108
107
|
should.exist(result);
|
|
@@ -116,7 +115,7 @@ describe('Deal', function() {
|
|
|
116
115
|
});
|
|
117
116
|
|
|
118
117
|
it('gets a deal by id', function(done) {
|
|
119
|
-
Deal.getById(dealId, function(err, result) {
|
|
118
|
+
Deal.getById(dealId, { CUSTOMER_ID: customer._id }, function(err, result) {
|
|
120
119
|
should.not.exist(err);
|
|
121
120
|
should.exist(result);
|
|
122
121
|
result._id.toString().should.equal(dealId.toString());
|
|
@@ -126,14 +125,14 @@ describe('Deal', function() {
|
|
|
126
125
|
|
|
127
126
|
it('adds a document to a deal', function(done) {
|
|
128
127
|
|
|
129
|
-
Deal.getById(dealId, function(err, deal) {
|
|
128
|
+
Deal.getById(dealId, { CUSTOMER_ID: customer._id }, function(err, deal) {
|
|
130
129
|
|
|
131
130
|
should.not.exist(err);
|
|
132
131
|
should.exist(deal);
|
|
133
132
|
|
|
134
133
|
deal.documents.push(new mongoose.Types.ObjectId());
|
|
135
134
|
|
|
136
|
-
Deal.upsert(deal, account, function(err, result) {
|
|
135
|
+
Deal.upsert(deal, { account: account, CUSTOMER_ID: customer._id }, function(err, result) {
|
|
137
136
|
|
|
138
137
|
should.not.exist(err);
|
|
139
138
|
should.exist(result);
|
|
@@ -147,14 +146,14 @@ describe('Deal', function() {
|
|
|
147
146
|
|
|
148
147
|
it('changes the deal stage', function(done) {
|
|
149
148
|
|
|
150
|
-
Deal.getById(dealId, function(err, deal) {
|
|
149
|
+
Deal.getById(dealId, { CUSTOMER_ID: customer._id }, function(err, deal) {
|
|
151
150
|
|
|
152
151
|
should.not.exist(err);
|
|
153
152
|
should.exist(deal);
|
|
154
153
|
|
|
155
154
|
deal.stage = 'Pass';
|
|
156
155
|
|
|
157
|
-
Deal.upsert(deal, account, function(err, result) {
|
|
156
|
+
Deal.upsert(deal, { account: account, CUSTOMER_ID: customer._id }, function(err, result) {
|
|
158
157
|
|
|
159
158
|
should.not.exist(err);
|
|
160
159
|
should.exist(result);
|
|
@@ -168,7 +167,7 @@ describe('Deal', function() {
|
|
|
168
167
|
|
|
169
168
|
it('modifies a deal by id', function (done) {
|
|
170
169
|
|
|
171
|
-
Deal.getById(dealId, function(err, deal) {
|
|
170
|
+
Deal.getById(dealId, { CUSTOMER_ID: customer._id }, function(err, deal) {
|
|
172
171
|
|
|
173
172
|
should.not.exist(err);
|
|
174
173
|
should.exist(deal);
|
|
@@ -182,7 +181,7 @@ describe('Deal', function() {
|
|
|
182
181
|
}
|
|
183
182
|
};
|
|
184
183
|
|
|
185
|
-
Deal.modifyById(dealId, update, function (err, result) {
|
|
184
|
+
Deal.modifyById(dealId, update, { CUSTOMER_ID: customer._id }, function (err, result) {
|
|
186
185
|
should.not.exist(err);
|
|
187
186
|
should.exist(result);
|
|
188
187
|
result.source.person.toString().should.equal(newSource.toString());
|
|
@@ -201,7 +200,7 @@ describe('Deal', function() {
|
|
|
201
200
|
stage: 'New'
|
|
202
201
|
});
|
|
203
202
|
|
|
204
|
-
Deal.upsert(d, account, function(err, result) {
|
|
203
|
+
Deal.upsert(d, { account: account, CUSTOMER_ID: customer._id }, function(err, result) {
|
|
205
204
|
|
|
206
205
|
should.not.exist(err);
|
|
207
206
|
should.exist(result);
|
|
@@ -212,12 +211,12 @@ describe('Deal', function() {
|
|
|
212
211
|
stage: 'New'
|
|
213
212
|
});
|
|
214
213
|
|
|
215
|
-
Deal.upsert(d, account, function(err, result) {
|
|
214
|
+
Deal.upsert(d, { account: account, CUSTOMER_ID: customer._id }, function(err, result) {
|
|
216
215
|
|
|
217
216
|
should.not.exist(err);
|
|
218
217
|
should.exist(result);
|
|
219
218
|
|
|
220
|
-
Deal.getForCustomer(
|
|
219
|
+
Deal.getForCustomer(customer._id, {}, function(err, result) {
|
|
221
220
|
|
|
222
221
|
should.not.exist(err);
|
|
223
222
|
should.exist(result)
|
|
@@ -240,7 +239,7 @@ describe('Deal', function() {
|
|
|
240
239
|
|
|
241
240
|
it('gets new deals for a customer', function(done) {
|
|
242
241
|
|
|
243
|
-
Deal.getForCustomer(
|
|
242
|
+
Deal.getForCustomer(customer._id, { since: timestamps[0] }, function(err, result) {
|
|
244
243
|
|
|
245
244
|
should.not.exist(err);
|
|
246
245
|
should.exist(result);
|
|
@@ -253,23 +252,8 @@ describe('Deal', function() {
|
|
|
253
252
|
|
|
254
253
|
});
|
|
255
254
|
|
|
256
|
-
it('gets all deals', function(done) {
|
|
257
|
-
|
|
258
|
-
var temp = config.CUSTOMER_ID;
|
|
259
|
-
config.CUSTOMER_ID = 'GLOBAL_PROCESS';
|
|
260
|
-
|
|
261
|
-
Deal.getAll(function(err, result) {
|
|
262
|
-
should.not.exist(err);
|
|
263
|
-
should.exist(result)
|
|
264
|
-
result.length.should.equal(3);
|
|
265
|
-
config.CUSTOMER_ID = temp;
|
|
266
|
-
return done();
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
});
|
|
270
|
-
|
|
271
255
|
it('deletes a deal', function(done) {
|
|
272
|
-
Deal.delete(dealId, function(err, result) {
|
|
256
|
+
Deal.delete(dealId, { CUSTOMER_ID: customer._id }, function(err, result) {
|
|
273
257
|
should.not.exist(err);
|
|
274
258
|
should.exist(result);
|
|
275
259
|
return done();
|
package/test/Document.js
CHANGED
|
@@ -28,29 +28,17 @@ describe('Document', function() {
|
|
|
28
28
|
clearDB(done);
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
before(function (done) {
|
|
32
|
-
Person.collection.dropIndexes(function (err, result) {
|
|
33
|
-
should.not.exist(err);
|
|
34
|
-
should.exist(result);
|
|
35
|
-
result.should.equal(true);
|
|
36
|
-
return done();
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
|
|
40
31
|
before(function(done) {
|
|
41
32
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
totemCustomerId: config.CUSTOMER_ID,
|
|
46
|
-
summary: 'Test'
|
|
47
|
-
});
|
|
33
|
+
org = new Organization();
|
|
34
|
+
org.name = 'Big Org';
|
|
35
|
+
org.slug = 'big-org';
|
|
48
36
|
|
|
49
|
-
|
|
37
|
+
Organization.upsert(org, 'test', function(err, result) {
|
|
50
38
|
|
|
51
39
|
should.not.exist(err);
|
|
52
40
|
should.exist(result);
|
|
53
|
-
|
|
41
|
+
org = result;
|
|
54
42
|
|
|
55
43
|
return done();
|
|
56
44
|
|
|
@@ -58,21 +46,20 @@ describe('Document', function() {
|
|
|
58
46
|
|
|
59
47
|
});
|
|
60
48
|
|
|
61
|
-
before(function(done) {
|
|
49
|
+
before(function (done) {
|
|
62
50
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
raw: { test: 'test' }
|
|
69
|
-
});
|
|
51
|
+
account = new Account();
|
|
52
|
+
account.username = 'test-user';
|
|
53
|
+
account.email = 'test@totemvc.com';
|
|
54
|
+
account.person = new mongoose.Types.ObjectId();
|
|
55
|
+
account.org = org;
|
|
70
56
|
|
|
71
|
-
|
|
57
|
+
Account.upsert(account, function (err, result) {
|
|
72
58
|
|
|
73
59
|
should.not.exist(err);
|
|
74
60
|
should.exist(result);
|
|
75
|
-
|
|
61
|
+
|
|
62
|
+
account = result;
|
|
76
63
|
|
|
77
64
|
return done();
|
|
78
65
|
|
|
@@ -80,17 +67,29 @@ describe('Document', function() {
|
|
|
80
67
|
|
|
81
68
|
});
|
|
82
69
|
|
|
70
|
+
before(function (done) {
|
|
71
|
+
Person.collection.dropIndexes(function (err, result) {
|
|
72
|
+
should.not.exist(err);
|
|
73
|
+
should.exist(result);
|
|
74
|
+
result.should.equal(true);
|
|
75
|
+
return done();
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
83
79
|
before(function(done) {
|
|
84
80
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
interaction = new Interaction({
|
|
82
|
+
calendarEventId: new mongoose.Types.ObjectId(),
|
|
83
|
+
providerEventId: 'abc123',
|
|
84
|
+
totemCustomerId: account.org._id,
|
|
85
|
+
summary: 'Test'
|
|
86
|
+
});
|
|
88
87
|
|
|
89
|
-
|
|
88
|
+
Interaction.upsert(interaction, function(err, result) {
|
|
90
89
|
|
|
91
90
|
should.not.exist(err);
|
|
92
91
|
should.exist(result);
|
|
93
|
-
|
|
92
|
+
interaction = result;
|
|
94
93
|
|
|
95
94
|
return done();
|
|
96
95
|
|
|
@@ -98,19 +97,21 @@ describe('Document', function() {
|
|
|
98
97
|
|
|
99
98
|
});
|
|
100
99
|
|
|
101
|
-
before(function
|
|
100
|
+
before(function(done) {
|
|
102
101
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
102
|
+
message = new Message({
|
|
103
|
+
webhook: new mongoose.Types.ObjectId(),
|
|
104
|
+
customer: account.org._id,
|
|
105
|
+
type: 'email',
|
|
106
|
+
subtype: 'boards',
|
|
107
|
+
raw: { test: 'test' }
|
|
108
|
+
});
|
|
107
109
|
|
|
108
|
-
|
|
110
|
+
Message.upsert(message, function(err, result) {
|
|
109
111
|
|
|
110
112
|
should.not.exist(err);
|
|
111
113
|
should.exist(result);
|
|
112
|
-
|
|
113
|
-
account = result;
|
|
114
|
+
message = result;
|
|
114
115
|
|
|
115
116
|
return done();
|
|
116
117
|
|
|
@@ -125,7 +126,7 @@ describe('Document', function() {
|
|
|
125
126
|
deal.organization = new mongoose.Types.ObjectId();
|
|
126
127
|
deal.stage = 'New';
|
|
127
128
|
|
|
128
|
-
Deal.upsert(deal, account, function(err, result) {
|
|
129
|
+
Deal.upsert(deal, { account: account, CUSTOMER_ID: account.org._id }, function(err, result) {
|
|
129
130
|
|
|
130
131
|
should.not.exist(err);
|
|
131
132
|
should.exist(result);
|
|
@@ -182,7 +183,7 @@ describe('Document', function() {
|
|
|
182
183
|
it('creates a document for an interaction', function(done) {
|
|
183
184
|
|
|
184
185
|
Document.createForModel({
|
|
185
|
-
customer:
|
|
186
|
+
customer: account.org._id,
|
|
186
187
|
createdBy: documentCreator,
|
|
187
188
|
name: 'your_mom.doc',
|
|
188
189
|
contentType: 'application/doc',
|
|
@@ -209,7 +210,7 @@ describe('Document', function() {
|
|
|
209
210
|
it('creates a document for a message', function(done) {
|
|
210
211
|
|
|
211
212
|
Document.createForModel({
|
|
212
|
-
customer:
|
|
213
|
+
customer: account.org._id,
|
|
213
214
|
createdBy: documentCreator,
|
|
214
215
|
name: 'plain.txt',
|
|
215
216
|
contentType: 'text/plain',
|
|
@@ -236,7 +237,7 @@ describe('Document', function() {
|
|
|
236
237
|
it('creates a document for an organization', function(done) {
|
|
237
238
|
|
|
238
239
|
Document.createForModel({
|
|
239
|
-
customer:
|
|
240
|
+
customer: account.org._id,
|
|
240
241
|
createdBy: documentCreator,
|
|
241
242
|
name: 'test_file.jpg',
|
|
242
243
|
contentType: 'image/jpeg',
|
|
@@ -265,7 +266,7 @@ describe('Document', function() {
|
|
|
265
266
|
it('creates a document for a person', function(done) {
|
|
266
267
|
|
|
267
268
|
Document.createForModel({
|
|
268
|
-
customer:
|
|
269
|
+
customer: account.org._id,
|
|
269
270
|
createdBy: documentCreator,
|
|
270
271
|
name: 'test.pdf',
|
|
271
272
|
contentType: 'application/pdf',
|
|
@@ -292,7 +293,7 @@ describe('Document', function() {
|
|
|
292
293
|
it('creates a document for a deal', function(done) {
|
|
293
294
|
|
|
294
295
|
Document.createForModel({
|
|
295
|
-
customer:
|
|
296
|
+
customer: account.org._id,
|
|
296
297
|
createdBy: documentCreator,
|
|
297
298
|
name: 'test.pdf',
|
|
298
299
|
contentType: 'application/pdf',
|
|
@@ -317,7 +318,7 @@ describe('Document', function() {
|
|
|
317
318
|
});
|
|
318
319
|
|
|
319
320
|
it('gets a document by id', function(done) {
|
|
320
|
-
Document.getById(documentId, function(err, result) {
|
|
321
|
+
Document.getById(documentId, { CUSTOMER_ID: account.org._id }, function(err, result) {
|
|
321
322
|
should.not.exist(err);
|
|
322
323
|
should.exist(result);
|
|
323
324
|
result.name.should.equal('test_file.jpg');
|
|
@@ -327,7 +328,7 @@ describe('Document', function() {
|
|
|
327
328
|
|
|
328
329
|
it('modifies a doc by id', function (done) {
|
|
329
330
|
|
|
330
|
-
Document.getById(documentId, function(err, doc) {
|
|
331
|
+
Document.getById(documentId, { CUSTOMER_ID: account.org._id }, function(err, doc) {
|
|
331
332
|
|
|
332
333
|
should.not.exist(err);
|
|
333
334
|
should.exist(doc);
|
|
@@ -341,7 +342,7 @@ describe('Document', function() {
|
|
|
341
342
|
}
|
|
342
343
|
};
|
|
343
344
|
|
|
344
|
-
Document.modifyById(documentId, update, function (err, result) {
|
|
345
|
+
Document.modifyById(documentId, update, { CUSTOMER_ID: account.org._id }, function (err, result) {
|
|
345
346
|
should.not.exist(err);
|
|
346
347
|
should.exist(result);
|
|
347
348
|
result.createdBy.toString().should.equal(newCreatedBy.toString());
|
|
@@ -353,7 +354,7 @@ describe('Document', function() {
|
|
|
353
354
|
});
|
|
354
355
|
|
|
355
356
|
it('deletes a document', function(done) {
|
|
356
|
-
Document.delete(documentId, function(err, result) {
|
|
357
|
+
Document.delete(documentId, { CUSTOMER_ID: account.org._id }, function(err, result) {
|
|
357
358
|
should.not.exist(err);
|
|
358
359
|
should.exist(result);
|
|
359
360
|
return done();
|
package/test/Financials.js
CHANGED
|
@@ -88,10 +88,12 @@ describe('Financials', function() {
|
|
|
88
88
|
});
|
|
89
89
|
|
|
90
90
|
// getByOrg
|
|
91
|
+
// getByPostmarkMessageId
|
|
91
92
|
// getByUUID
|
|
92
93
|
// getForCampaign
|
|
93
94
|
// getForCustomer
|
|
94
|
-
//
|
|
95
|
+
// getUUIDsToSendInitial
|
|
96
|
+
// getUUIDsToSendReminder
|
|
95
97
|
// removeCustomerFinancials
|
|
96
98
|
// upsert
|
|
97
99
|
|
|
@@ -129,9 +131,9 @@ describe('Financials', function() {
|
|
|
129
131
|
|
|
130
132
|
});
|
|
131
133
|
|
|
132
|
-
it('removes financials for a customer', function(done) {
|
|
134
|
+
it.skip('removes financials for a customer', function(done) {
|
|
133
135
|
|
|
134
|
-
config.CUSTOMER_ID = customerA;
|
|
136
|
+
//config.CUSTOMER_ID = customerA;
|
|
135
137
|
|
|
136
138
|
Financials.find({}, function(err, result) {
|
|
137
139
|
|
package/test/Flag.js
CHANGED
|
@@ -29,15 +29,15 @@ describe('Flag', function() {
|
|
|
29
29
|
|
|
30
30
|
before(function(done) {
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
org = new Organization();
|
|
33
|
+
org.name = 'Big Org';
|
|
34
|
+
org.slug = 'big-org';
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
Organization.upsert(org, 'test', function(err, result) {
|
|
37
37
|
|
|
38
38
|
should.not.exist(err);
|
|
39
39
|
should.exist(result);
|
|
40
|
-
|
|
40
|
+
org = result;
|
|
41
41
|
|
|
42
42
|
return done();
|
|
43
43
|
|
|
@@ -47,15 +47,16 @@ describe('Flag', function() {
|
|
|
47
47
|
|
|
48
48
|
before(function(done) {
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
lp = new LimitedPartner();
|
|
51
|
+
lp.name = 'Big LP';
|
|
52
|
+
lp.slug = 'big-lp';
|
|
53
|
+
lp.customer = org;
|
|
53
54
|
|
|
54
|
-
|
|
55
|
+
LimitedPartner.upsert(lp, 'test', { role: 'lp-full' }, function(err, result) {
|
|
55
56
|
|
|
56
57
|
should.not.exist(err);
|
|
57
58
|
should.exist(result);
|
|
58
|
-
|
|
59
|
+
lp = result;
|
|
59
60
|
|
|
60
61
|
return done();
|
|
61
62
|
|
|
@@ -172,7 +173,8 @@ describe('Flag', function() {
|
|
|
172
173
|
|
|
173
174
|
Flag.createForModel({
|
|
174
175
|
createdBy: flagCreator,
|
|
175
|
-
text: 'Best flag ever!'
|
|
176
|
+
text: 'Best flag ever!',
|
|
177
|
+
customer: org
|
|
176
178
|
}, Organization, org._id, function(err, result) {
|
|
177
179
|
|
|
178
180
|
should.not.exist(err);
|
|
@@ -193,7 +195,8 @@ describe('Flag', function() {
|
|
|
193
195
|
|
|
194
196
|
Flag.createForModel({
|
|
195
197
|
createdBy: flagCreator,
|
|
196
|
-
text: 'Best flag ever!'
|
|
198
|
+
text: 'Best flag ever!',
|
|
199
|
+
customer: org
|
|
197
200
|
}, LimitedPartner, lp._id, function(err, result) {
|
|
198
201
|
|
|
199
202
|
should.not.exist(err);
|
|
@@ -212,7 +215,8 @@ describe('Flag', function() {
|
|
|
212
215
|
|
|
213
216
|
Flag.createForModel({
|
|
214
217
|
createdBy: flagCreator,
|
|
215
|
-
text: 'Best flag ever!'
|
|
218
|
+
text: 'Best flag ever!',
|
|
219
|
+
customer: org
|
|
216
220
|
}, Person, person._id, function(err, result) {
|
|
217
221
|
|
|
218
222
|
should.not.exist(err);
|
|
@@ -264,7 +268,7 @@ describe('Flag', function() {
|
|
|
264
268
|
});
|
|
265
269
|
|
|
266
270
|
it('deletes a flag', function(done) {
|
|
267
|
-
Flag.delete(flagId, function(err, result) {
|
|
271
|
+
Flag.delete(flagId, org._id, function(err, result) {
|
|
268
272
|
should.not.exist(err);
|
|
269
273
|
should.exist(result);
|
|
270
274
|
return done();
|
package/test/Interaction.js
CHANGED
|
@@ -82,9 +82,7 @@ describe('Interaction', function() {
|
|
|
82
82
|
|
|
83
83
|
it('gets interactions for a person', function(done) {
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
Interaction.getForPeople([externalAttendee1], { before: moment().add(1, 'hour').toISOString()}, function(err, result) {
|
|
85
|
+
Interaction.getForPeople([externalAttendee1], { CUSTOMER_ID: totemCustomerId1, before: moment().add(1, 'hour').toISOString()}, function(err, result) {
|
|
88
86
|
should.not.exist(err);
|
|
89
87
|
should.exist(result);
|
|
90
88
|
result.length.should.equal(1);
|
|
@@ -94,36 +92,8 @@ describe('Interaction', function() {
|
|
|
94
92
|
|
|
95
93
|
});
|
|
96
94
|
|
|
97
|
-
it('tries to get interactions for a person as an admin process', function(done) {
|
|
98
|
-
|
|
99
|
-
config.CUSTOMER_ID = 'GLOBAL_PROCESS';
|
|
100
|
-
|
|
101
|
-
Interaction.getForPeople([externalAttendee1], { before: moment().add(1, 'hour').toISOString()}, function(err, result) {
|
|
102
|
-
should.exist(err);
|
|
103
|
-
should.not.exist(result);
|
|
104
|
-
done();
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it('gets interactions for a person as an admin process', function(done) {
|
|
110
|
-
|
|
111
|
-
config.CUSTOMER_ID = totemCustomerId2;
|
|
112
|
-
|
|
113
|
-
Interaction.getForPeople([externalAttendee2], { before: moment().add(1, 'hour').toISOString()}, function(err, result) {
|
|
114
|
-
should.not.exist(err);
|
|
115
|
-
should.exist(result);
|
|
116
|
-
result.length.should.equal(1);
|
|
117
|
-
result[0].summary.should.equal('test 2');
|
|
118
|
-
done();
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
});
|
|
122
|
-
|
|
123
95
|
it('gets interactions for a customer', function(done) {
|
|
124
96
|
|
|
125
|
-
config.CUSTOMER_ID = totemCustomerId2;
|
|
126
|
-
|
|
127
97
|
var interaction = new Interaction({
|
|
128
98
|
calendarEventId: new mongoose.Types.ObjectId(),
|
|
129
99
|
providerEventId: 'abc124',
|