@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/test/Person.js CHANGED
@@ -11,12 +11,8 @@ var
11
11
  Person = mongoose.model('Person'),
12
12
  Organization = mongoose.model('Organization'),
13
13
  Account = mongoose.model('Account'),
14
- Note = mongoose.model('Note'),
15
14
  person = new Person(),
16
- mergeId = new mongoose.Types.ObjectId(),
17
- noteId;
18
-
19
- var CUSTOMER_ID = config.CUSTOMER_ID;
15
+ mergeId = new mongoose.Types.ObjectId();
20
16
 
21
17
  var person2, person3, person4, person5;
22
18
 
@@ -103,15 +99,6 @@ describe('Person', function() {
103
99
  });
104
100
  });
105
101
 
106
- before(function (done) {
107
- Person.setCustomerCompanyIds([
108
- org._id.toString(),
109
- org3._id.toString(),
110
- org4._id.toString()
111
- ]);
112
- done();
113
- });
114
-
115
102
  before(function (done) {
116
103
 
117
104
  person2 = new Person();
@@ -232,26 +219,6 @@ describe('Person', function() {
232
219
 
233
220
  }); // end adds a person
234
221
 
235
- it.skip('tries to add another person with the same email', function(done) {
236
-
237
- var p = new Person();
238
- p.name.first = 'Jesty';
239
- p.name.last = 'McJester';
240
- p.slug = 'jesty-mcjester';
241
-
242
- p.contact.email.push({
243
- type: 'work',
244
- email: 'dhyasama+test@gmail.com',
245
- primary: true
246
- });
247
-
248
- Person.upsert(p, 'test', function(err, updatedPerson) {
249
- should.exist(err);
250
- done();
251
- });
252
-
253
- });
254
-
255
222
  it('it relates 2 people', function(done) {
256
223
 
257
224
  person2.relatePerson(person.id);
@@ -575,45 +542,6 @@ describe('Person', function() {
575
542
 
576
543
  });
577
544
 
578
- it('finds dupes with separate first and last search', function(done) {
579
-
580
- var options = {
581
- fuzzy: false,
582
- andFirstLast: false,
583
- admin: true
584
- };
585
-
586
- Person.findDupes(person2, options, function(err, dupes) {
587
- should.not.exist(err);
588
- should.exist(dupes);
589
- dupes.length.should.equal(1);
590
- done();
591
- });
592
-
593
- });
594
-
595
- it('flags a person', function(done) {
596
-
597
- Person.flag(person.id, false, 'test flag', 'tester', function(err, updatedPerson) {
598
- should.not.exist(err);
599
- should.exist(updatedPerson);
600
- should.exist(updatedPerson.flagged);
601
- updatedPerson.flagged.resolved.should.equal(false);
602
- done();
603
- });
604
-
605
- });
606
-
607
- it('does not flag a non-existent person', function(done) {
608
-
609
- Person.flag(new mongoose.Types.ObjectId(), false, 'test flag', 'tester', function(err, updatedPerson) {
610
- should.exist(err);
611
- should.not.exist(updatedPerson);
612
- done();
613
- });
614
-
615
- });
616
-
617
545
  it('adds an account to a person', function(done) {
618
546
 
619
547
  var account = new Account();
@@ -645,7 +573,7 @@ describe('Person', function() {
645
573
  done();
646
574
  });
647
575
 
648
- it('lists the funds for a person', function(done) {
576
+ it.skip('lists the funds for a person', function(done) {
649
577
  // todo - not sure how to test this since it's tight with LimitedPartner
650
578
  done();
651
579
  });
@@ -664,22 +592,6 @@ describe('Person', function() {
664
592
 
665
593
  });
666
594
 
667
- it('lists all people', function(done) {
668
-
669
- Person.listAllPeople(function(err, people) {
670
- should.not.exist(err);
671
- should.exist(people);
672
- //because of the soft delete test
673
- people.length.should.equal(4);
674
- done();
675
- });
676
-
677
- });
678
-
679
-
680
-
681
-
682
-
683
595
  it('finds person by facebook with http and no www', function (done) {
684
596
  Person.findBySocial('http://facebook.com/slipperypete', function (err, result) {
685
597
  should.not.exist(err);
@@ -779,68 +691,9 @@ describe('Person', function() {
779
691
  });
780
692
  });
781
693
 
782
-
783
-
784
-
785
-
786
-
787
-
788
- it('finds person by slug', function(done) {
789
-
790
- Person.findBySlug('person3-slug', function(err, p) {
791
- should.not.exist(err);
792
- should.exist(p);
793
- p.length.should.equal(1);
794
- done();
795
- });
796
-
797
- });
798
-
799
- it('finds people by slugs', function(done) {
800
-
801
- Person.findBySlugs(['tim-reynolds', 'person3-slug'], function(err, people) {
802
- should.not.exist(err);
803
- should.exist(people);
804
- people.length.should.equal(2);
805
- done();
806
- });
807
-
808
- });
809
-
810
- it('finds people by slugs without a match', function(done) {
811
-
812
- Person.findBySlugs(['sweet-jesus-42', 'easy-as-abc-123'], function(err, people) {
813
- should.not.exist(err);
814
- should.exist(people);
815
- people.length.should.equal(0);
816
- done();
817
- });
818
-
819
- });
820
-
821
- it('finds a user by email', function(done) {
822
-
823
- Person.findByUniqueInfo('dhyasama+test@gmail.com', function(err, person) {
824
- should.not.exist(err);
825
- should.exist(person);
826
- done();
827
- });
828
-
829
- });
830
-
831
- it("doesn't find a user if email doesn't exist", function(done) {
832
-
833
- Person.findByUniqueInfo('mcfly@delorean.com', function(err, person) {
834
- should.not.exist(err);
835
- should.not.exist(person);
836
- done();
837
- });
838
-
839
- });
840
-
841
694
  it('finds a person by id', function(done) {
842
695
 
843
- Person.getById(person.id, function(err, person) {
696
+ Person.getById(person.id, { CUSTOMER_ID: org._id }, function(err, person) {
844
697
  should.not.exist(err);
845
698
  should.exist(person);
846
699
  done();
@@ -850,31 +703,9 @@ describe('Person', function() {
850
703
 
851
704
  it('finds a person by id and populates', function(done) {
852
705
 
853
- Person.getById(person5.id, function(err, person) {
854
- should.not.exist(err);
855
- should.exist(person);
856
- done();
857
- });
858
-
859
- });
860
-
861
- it('finds a person without mongoose sugar', function(done) {
862
-
863
- Person.getByIdRaw(person5._id, function(err, person) {
706
+ Person.getById(person5.id, { CUSTOMER_ID: org._id }, function(err, person) {
864
707
  should.not.exist(err);
865
708
  should.exist(person);
866
- (person instanceof Person).should.equal(false);
867
- done();
868
- });
869
-
870
- });
871
-
872
- it('finds a person as global', function (done) {
873
-
874
- Person.getByIdAsGlobal(person5._id, {}, function (err, result) {
875
- should.not.exist(err);
876
- should.exist(result);
877
- result.sources.length.should.equal(1);
878
709
  done();
879
710
  });
880
711
 
@@ -882,7 +713,7 @@ describe('Person', function() {
882
713
 
883
714
  it('finds the primary email for a person', function(done) {
884
715
 
885
- Person.getById(person.id, function(err, person) {
716
+ Person.getById(person.id, { CUSTOMER_ID: org._id }, function(err, person) {
886
717
 
887
718
  should.not.exist(err);
888
719
  should.exist(person);
@@ -897,7 +728,7 @@ describe('Person', function() {
897
728
 
898
729
  it('finds the primary phone for a person', function(done) {
899
730
 
900
- Person.getById(person.id, function(err, person) {
731
+ Person.getById(person.id, { CUSTOMER_ID: org._id }, function(err, person) {
901
732
 
902
733
  should.not.exist(err);
903
734
  should.exist(person);
@@ -926,84 +757,6 @@ describe('Person', function() {
926
757
 
927
758
  });
928
759
 
929
- it('it flags a person', function(done) {
930
-
931
- Person.flag(person2.id, false, 'flagging person2', 'test-user', function(err, p) {
932
- should.not.exist(err);
933
- should.exist(p);
934
- p.flagged.text.should.equal('flagging person2');
935
- person2 = p;
936
- done();
937
- });
938
- });
939
-
940
- it('does not find dupes with conjoined first and last search', function(done) {
941
-
942
- var options = {
943
- fuzzy: true,
944
- andFirstLast: true
945
- };
946
-
947
- person2.contact.phone = [];
948
-
949
- Person.findDupes(person2, options, function(err, dupes) {
950
- should.not.exist(err);
951
- should.exist(dupes);
952
- dupes.length.should.equal(0);
953
- done();
954
- });
955
-
956
- });
957
-
958
- it('finds dupes while ignoring short last name', function(done) {
959
-
960
- var options = {
961
- fuzzy: true,
962
- andFirstLast: true
963
- };
964
-
965
- person2.name.last = 'M';
966
-
967
- Person.findDupes(person2, options, function(err, dupes) {
968
- should.not.exist(err);
969
- should.exist(dupes);
970
- dupes.length.should.equal(0);
971
- done();
972
- });
973
-
974
- });
975
-
976
- it('adds a note to a person', function(done) {
977
-
978
- Person.addNote(person2.id, person3.id, 'Sweet note bro!', false, function(err, result) {
979
-
980
- should.not.exist(err);
981
- should.exist(result);
982
- should.exist(result.note);
983
- should.exist(result.addedTo);
984
- result.addedTo.notes.length.should.equal(1);
985
- result.addedTo.id.toString().should.equal(person2.id.toString());
986
-
987
- noteId = result.addedTo.notes[0];
988
-
989
- return done();
990
-
991
- });
992
-
993
- });
994
-
995
- it('deletes a simple note', function(done) {
996
-
997
- Person.deleteNote(noteId, function(err, result) {
998
-
999
- should.not.exist(err);
1000
-
1001
- return done();
1002
-
1003
- });
1004
-
1005
- });
1006
-
1007
760
  it('cleans contact info', function(done) {
1008
761
 
1009
762
  var p = new Person();
package/test/Round.js CHANGED
@@ -110,7 +110,7 @@ describe('Rounds', function() {
110
110
  before(function(done) {
111
111
 
112
112
  var inv = new Investment({
113
- customer: config.CUSTOMER_ID,
113
+ customer: organization,
114
114
  cost: 200000,
115
115
  costPlusInterest: 200000,
116
116
  investmentDate: Date.now(),
@@ -132,7 +132,7 @@ describe('Rounds', function() {
132
132
  before(function(done) {
133
133
 
134
134
  var inv = new Investment({
135
- customer: config.CUSTOMER_ID,
135
+ customer: organization,
136
136
  cost: 200000,
137
137
  costPlusInterest: 200000,
138
138
  investmentDate: Date.now(),
@@ -186,7 +186,7 @@ describe('Rounds', function() {
186
186
  should.not.exist(err);
187
187
  should.exist(result);
188
188
 
189
- Round.getByOrg(organization, function(err, rounds) {
189
+ Round.getByOrg(organization._id, { CUSTOMER_ID: organization._id }, function(err, rounds) {
190
190
  should.not.exist(err);
191
191
  should.exist(rounds);
192
192
  rounds.length.should.equal(2);
@@ -316,7 +316,7 @@ describe('Rounds', function() {
316
316
  rounds.length.should.be.greaterThan(0);
317
317
 
318
318
  var round = rounds[0];
319
- var numberOfVehicles = round.vehicles.length; console.log('numberOfVehicles', numberOfVehicles);
319
+ //var numberOfVehicles = round.vehicles.length; console.log('numberOfVehicles', numberOfVehicles);
320
320
 
321
321
  Round.removeVehicle(round._id, fundid, function(err, result) {
322
322
 
@@ -402,7 +402,7 @@ describe('Rounds', function() {
402
402
  should.not.exist(err);
403
403
  should.exist(result);
404
404
 
405
- Round.getPortfolioByPerson(personid, function(err, result) {
405
+ Round.getPortfolioByPerson(personid, { CUSTOMER_ID: organization._id }, function(err, result) {
406
406
  should.exist(err);
407
407
  err.message.should.equal('Round.getPortfolioByPerson has one or more orgs that is not populated which means there is bad data');
408
408
  done();
@@ -432,7 +432,7 @@ describe('Rounds', function() {
432
432
  should.not.exist(err);
433
433
  should.exist(result);
434
434
 
435
- Round.getPortfolioByPerson(personid, function(err, result) {
435
+ Round.getPortfolioByPerson(personid, { CUSTOMER_ID: organization._id }, function(err, result) {
436
436
  should.not.exist(err);
437
437
  should.exist(result);
438
438
  done();
@@ -467,7 +467,7 @@ describe('Rounds', function() {
467
467
  should.not.exist(err);
468
468
  should.exist(result);
469
469
 
470
- Round.getPortfolioByFunds([fund._id], function(err, result) {
470
+ Round.getPortfolioByFunds([fund._id], { CUSTOMER_ID: organization._id }, function(err, result) {
471
471
 
472
472
  should.not.exist(err);
473
473
  should.exist(result);
@@ -496,7 +496,7 @@ describe('Rounds', function() {
496
496
 
497
497
  it('gets the portfolio of two funds', function(done) {
498
498
 
499
- Round.getPortfolioByFunds([fund._id, new mongoose.Types.ObjectId()], function(err, result) {
499
+ Round.getPortfolioByFunds([fund._id, new mongoose.Types.ObjectId()], { CUSTOMER_ID: organization._id }, function(err, result) {
500
500
  should.not.exist(err);
501
501
  should.exist(result);
502
502
  result.length.should.equal(2);
@@ -520,7 +520,7 @@ describe('Rounds', function() {
520
520
  o1 = result;
521
521
 
522
522
  var inv1 = new Investment({
523
- customer: config.CUSTOMER_ID,
523
+ customer: organization,
524
524
  investmentDate: Date.now(),
525
525
  preMoneyValuation: 2,
526
526
  dollarsRaised: 4,
@@ -547,7 +547,7 @@ describe('Rounds', function() {
547
547
  should.exist(result);
548
548
  r1 = result;
549
549
 
550
- Round.getByOrg(r1.organization, function(err, result) {
550
+ Round.getByOrg(r1.organization._id, { CUSTOMER_ID: organization._id }, function(err, result) {
551
551
 
552
552
  should.not.exist(err);
553
553
  should.exist(result);
@@ -608,7 +608,7 @@ describe('Rounds', function() {
608
608
  should.exist(result);
609
609
  r1 = result;
610
610
 
611
- Round.getByOrg(r1.organization, function(err, result) {
611
+ Round.getByOrg(r1.organization._id, { CUSTOMER_ID: organization._id }, function(err, result) {
612
612
 
613
613
  should.not.exist(err);
614
614
  should.exist(result);
package/lib/Sync.js DELETED
@@ -1,48 +0,0 @@
1
- "use strict";
2
-
3
- module.exports = function(mongoose, config) {
4
-
5
- var
6
-
7
- Schema = mongoose.Schema,
8
- env = process.env.NODE_ENV || 'development',
9
- _ = require('underscore');
10
-
11
- var Sync = new Schema({
12
- customer: { type: String, required: true },
13
- syncedOn: { type: Date, required: true },
14
- completedOn: { type: Date },
15
- syncedBy: { type: String, trim: true },
16
- steps: [{
17
- _id: false,
18
- name: { type: String, trim: true },
19
- tasks: [{
20
- _id: false,
21
- name: { type: String, trim: true },
22
- issues: [{ type: String, trim: true }],
23
- }]
24
- }]
25
- });
26
-
27
- Sync.statics.getById = function (id, customerId, cb) {
28
-
29
- var self = this;
30
-
31
- self.findOne({
32
- '_id': id,
33
- 'customer': customerId
34
- }).exec(cb);
35
-
36
- };
37
-
38
- Sync.statics.upsert = function(sync, cb) {
39
- sync.syncedOn = new Date();
40
- sync.save(cb);
41
- };
42
-
43
- Sync.set('autoIndex', false);
44
- Sync.set('usePushEach', true);
45
-
46
- mongoose.model('Sync', Sync, 'syncs');
47
-
48
- };