add support for user and document fixtures

This commit is contained in:
cleverbeagle 2017-05-27 15:34:21 -05:00
parent ec8a7b9228
commit e56cd9cf80
2 changed files with 35 additions and 14 deletions

View file

@ -2,32 +2,53 @@ import seeder from '@cleverbeagle/seeder';
import { Meteor } from 'meteor/meteor';
import Documents from '../../api/Documents/Documents';
const documentsSeed = userId => ({
collection: Documents,
environments: ['development', 'staging'],
noLimit: true,
modelCount: 5,
model(dataIndex) {
return {
owner: userId,
title: `Document #${dataIndex + 1}`,
body: `This is the body of document #${dataIndex + 1}`,
};
},
});
seeder(Meteor.users, {
environments: ['development', 'staging'],
noLimit: true,
data: [{
email: 'admin@admin.com',
password: 'password',
profile: {
name: {
first: 'George',
last: 'Clooney',
first: 'Andy',
last: 'Warhol',
},
},
roles: ['admin'],
data(userId) {
return documentsSeed(userId);
},
}],
});
seeder(Documents, {
environments: ['development', 'staging'],
wipe: true,
min: 10,
modelCount: 5,
model(index, faker) {
const owner = Meteor.users.findOne({ 'emails.address': 'admin@admin.com' })._id;
const documentNumber = index + 1;
const userCount = index + 1;
return {
owner,
title: `${faker.lorem.words(5)} #${documentNumber}`,
body: `This is the body of example document #${documentNumber}.`,
email: `user+${userCount}@test.com`,
password: 'password',
profile: {
name: {
first: faker.name.firstName(),
last: faker.name.lastName(),
},
},
roles: ['user'],
data(userId) {
return documentsSeed(userId);
},
};
},
});

View file

@ -7,7 +7,7 @@
},
"dependencies": {
"@cleverbeagle/dates": "^0.2.0",
"@cleverbeagle/seeder": "^0.3.0",
"@cleverbeagle/seeder": "^1.1.0",
"babel-runtime": "^6.20.0",
"bcrypt": "^1.0.2",
"jquery": "^2.2.4",