Skip to content

Commit 725b036

Browse files
committed
Fixed Fixtures
1 parent aa476c6 commit 725b036

File tree

14 files changed

+132
-134
lines changed

14 files changed

+132
-134
lines changed

.meteor/packages

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

77
## METEOR CORE
88
[email protected] # Packages every Meteor app needs to have
9-
[email protected].0 # The database Meteor supports right now
9+
[email protected].2 # The database Meteor supports right now
1010
[email protected] # Reactive variable for tracker
1111
[email protected] # Meteor's client-side reactive programming library
1212

1313
## PRODUCTION ENHANCEMENTS
14-
[email protected].4 # CSS minifier run for production mode
14+
[email protected].5 # CSS minifier run for production mode
1515
abernix:[email protected] # JS minifier
1616
[email protected] # ECMAScript 5 compatibility for older browsers.
1717

@@ -24,9 +24,9 @@ aldeed:schema-index
2424

2525
## TESTING
2626
meteortesting:mocha
27-
27+
2828

2929
## ACCOUNTS
30-
accounts-password@1.4.0
30+
accounts-password
3131
3232

.meteor/release

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1+

.meteor/versions

+10-10

both/collections/user.collection.ts

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import { Courses } from './course.collection';
1818

1919

20+
21+
2022
/**
2123
EXTEND USER COLLECTION
2224
**/

both/models/user.model.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
export interface Profile {
1010
name: string;
1111
organization: string;
12-
email: string;
1312
picture?: string;
1413
}
1514

@@ -28,8 +27,9 @@
2827

2928
/* USER MODEL */
3029
export interface User extends Meteor.User {
31-
_id? : string,
30+
_id? : string;
31+
username: string;
3232
profile: Profile;
33-
global_admin: boolean,
33+
global_admin: boolean;
3434
roles: Privilege[];
3535
}

both/schemas/user.schema.ts

+35-8
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ import { Role } from '../models/user.model';
1515
organization: {
1616
type: String
1717
},
18-
email: {
19-
type: String
20-
},
2118
picture: {
2219
type: String
2320
}
@@ -38,19 +35,49 @@ import { Role } from '../models/user.model';
3835

3936
/* User Schema */
4037
export const UserSchema : SimpleSchema = new SimpleSchema({
38+
_id: {
39+
type: String,
40+
regEx: SimpleSchema.RegEx.Id
41+
},
42+
username: {
43+
type: String,
44+
regEx: /^[a-z0-9A-Z_]{3,15}$/
45+
},
46+
emails: {
47+
optional: true,
48+
type: Array
49+
},
50+
"emails.$": {
51+
type: new SimpleSchema({
52+
address: {
53+
type: String,
54+
regEx: SimpleSchema.RegEx.Email
55+
},
56+
verified: {
57+
optional: true,
58+
type: Boolean
59+
}
60+
})
61+
},
62+
createdAt: {
63+
type: Date
64+
},
65+
profile: {
66+
type: profileSchema,
67+
optional: true
68+
},
4169
services: {
4270
type: Object,
4371
optional: true,
4472
blackbox: true
4573
},
46-
profile: {
47-
type: profileSchema
48-
},
4974
global_admin: {
50-
type: Boolean
75+
type: Boolean,
76+
optional: true
5177
},
5278
roles: {
53-
type: Array
79+
type: Array,
80+
optional: true
5481
},
5582
'roles.$': {
5683
type: privilegeSchema

client/imports/app.component.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Router, ActivatedRoute } from '@angular/router';
66
// Meteor
77
import { Meteor } from "meteor/meteor";
88
import { Tracker } from "meteor/tracker";
9+
import { Accounts } from "meteor/accounts-base";
910

1011
// User Model
1112
import { User } from '../../both/models/user.model';

imports/test/fixtures/index.ts

+52-86
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,6 @@
2525
import { Users } from '../../../both/collections/user.collection';
2626
import { addRoleForCourse } from '../../../server/methods/user.methods';
2727

28-
/*
29-
* cleanupDatabase
30-
* cleans up databases
31-
*/
32-
export function cleanupDatabase(){
33-
CourseRecords.remove({});
34-
Courses.remove({});
35-
Labs.remove({});
36-
Sessions.remove({});
37-
Users.remove({});
38-
}
39-
4028
/*
4129
* defaultFixtures
4230
*/
@@ -59,64 +47,60 @@
5947

6048
constructor(){
6149

50+
// Reset Database
51+
CourseRecords.remove({});
52+
Courses.remove({});
53+
Labs.remove({});
54+
Sessions.remove({});
55+
Users.remove({});
56+
6257
// Users
6358
this.users = {
64-
"global_admin": Users.insert({
65-
username: "global_admin",
66-
profile: {
67-
name : "Derek Brown",
68-
organization : "Carnegie Mellon University",
69-
email : "[email protected]",
70-
picture : "https://c2.staticflickr.com/4/3025/2414332460_bb710ed7b3.jpg"
71-
},
72-
global_admin: true,
73-
roles: []
74-
}, () => {
75-
Accounts.setPassword(this.users["global_admin"], "global_admin");
76-
}),
77-
78-
"course_admin": Users.insert({
79-
username: "course_admin",
80-
profile: {
81-
name : "Aaron Mortenson",
82-
organization : "Carnegie Mellon University",
83-
email : "[email protected]",
84-
picture : "https://c2.staticflickr.com/4/3025/2414332460_bb710ed7b3.jpg"
85-
},
86-
global_admin: false,
87-
roles: []
88-
}, () => {
89-
Accounts.setPassword(this.users["course_admin"], "course_admin");
90-
}),
91-
92-
"instructor": Users.insert({
93-
username: "instructor",
94-
profile: {
95-
name : "Sander Shi",
96-
organization : "Carnegie Mellon University",
97-
email : "[email protected]",
98-
picture : "https://c2.staticflickr.com/4/3025/2414332460_bb710ed7b3.jpg"
99-
},
100-
global_admin: false,
101-
roles: []
102-
}, () => {
103-
Accounts.setPassword(this.users["instructor"], "instructor");
104-
}),
105-
106-
"student": Users.insert({
107-
username: "student",
108-
profile: {
109-
name : "Cem Ersoz",
110-
organization : "Carnegie Mellon University",
111-
email : "[email protected]",
112-
picture : "https://c2.staticflickr.com/4/3025/2414332460_bb710ed7b3.jpg"
113-
},
114-
global_admin: false,
115-
roles: []
116-
}, () => {
117-
Accounts.setPassword(this.users["student"], "student");
118-
})
119-
};
59+
global_admin : <string> Accounts.createUser({
60+
username: "global_admin",
61+
62+
password: "global_admin",
63+
profile: {
64+
name : "Global Admin",
65+
organization : "Carnegie Mellon University",
66+
picture : "https://c2.staticflickr.com/4/3025/2414332460_bb710ed7b3.jpg"
67+
}
68+
}),
69+
70+
course_admin : <string> Accounts.createUser({
71+
username: "course_admin",
72+
73+
password: "course_admin",
74+
profile: {
75+
name : "Course Admin",
76+
organization : "Carnegie Mellon University",
77+
picture : "https://c2.staticflickr.com/4/3025/2414332460_bb710ed7b3.jpg"
78+
}
79+
}),
80+
81+
instructor : <string> Accounts.createUser({
82+
username: "instructor",
83+
84+
password: "instructor",
85+
profile: {
86+
name : "Instructor",
87+
organization : "Carnegie Mellon University",
88+
picture : "https://c2.staticflickr.com/4/3025/2414332460_bb710ed7b3.jpg"
89+
}
90+
}),
91+
92+
student : <string> Accounts.createUser({
93+
username: "student",
94+
95+
password: "student",
96+
profile: {
97+
name : "Student",
98+
organization : "Carnegie Mellon University",
99+
picture : "https://c2.staticflickr.com/4/3025/2414332460_bb710ed7b3.jpg"
100+
}
101+
})
102+
}
103+
Users.setGlobalAdministrator(this.users.global_admin, true);
120104

121105
// Courses
122106
this.courses = ({
@@ -187,22 +171,4 @@
187171
addRoleForCourse(this.courses.gpi, this.users.instructor, Role.instructor);
188172

189173
}
190-
191-
public destructor(){
192-
193-
// Delete Users
194-
_.forEach(this.users, function(value, key){
195-
Users.remove({ '_id' : value });
196-
})
197-
198-
// Delete Courses
199-
_.forEach(this.courses, function(value, key){
200-
Courses.remove({ '_id' : value });
201-
})
202-
203-
// Delete Labs
204-
_.forEach(this.labs, function(value, key){
205-
Labs.remove({ '_id' : value });
206-
})
207-
}
208174
}

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@types/dockerode": "^2.4.6",
1616
"@types/file-saver": "0.0.1",
1717
"@types/lodash": "^4.14.68",
18-
"@types/meteor": "^1.4.2",
18+
"@types/meteor": "1.4.2",
1919
"@types/node": "^8.0.15",
2020
"@types/node-cache": "^4.1.0",
2121
"@types/node-fibers": "0.0.28",
@@ -54,7 +54,7 @@
5454
"file-saver": "^1.3.3",
5555
"lodash": "^4.17.4",
5656
"meteor-node-stubs": "^0.2.11",
57-
"meteor-rxjs": "^0.4.7",
57+
"meteor-rxjs": "0.4.7",
5858
"node-cache": "^4.1.1",
5959
"node-etcd": "^5.1.0",
6060
"prismjs": "^1.6.0",

server/imports/runtime/lab_runtime.app-test.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import { expect } from 'chai';
88
import * as _ from 'lodash';
99

10-
import { DefaultFixtures, cleanupDatabase } from '../../../imports/test/fixtures';
10+
import { DefaultFixtures } from '../../../imports/test/fixtures';
1111
import { Example1 } from '../../../imports/test/fixtures/example_labs';
1212

1313
import { Lab, LabFileImportOpts } from '../../../both/models/lab.model';
@@ -24,14 +24,9 @@ export function runTest(){
2424
let lab_id_mongo : string;
2525

2626
before(function(){
27-
cleanupDatabase();
2827
fixtures = new DefaultFixtures();
2928
});
3029

31-
after(function(){
32-
fixtures.destructor();
33-
});
34-
3530
it('should import from file', function(){
3631
let record : LabFileImportOpts = {
3732
course_id: fixtures.courses.gpi,

0 commit comments

Comments
 (0)