add support for user and document fixtures
This commit is contained in:
parent
ec8a7b9228
commit
e56cd9cf80
2 changed files with 35 additions and 14 deletions
|
|
@ -2,32 +2,53 @@ import seeder from '@cleverbeagle/seeder';
|
||||||
import { Meteor } from 'meteor/meteor';
|
import { Meteor } from 'meteor/meteor';
|
||||||
import Documents from '../../api/Documents/Documents';
|
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, {
|
seeder(Meteor.users, {
|
||||||
environments: ['development', 'staging'],
|
environments: ['development', 'staging'],
|
||||||
|
noLimit: true,
|
||||||
data: [{
|
data: [{
|
||||||
email: 'admin@admin.com',
|
email: 'admin@admin.com',
|
||||||
password: 'password',
|
password: 'password',
|
||||||
profile: {
|
profile: {
|
||||||
name: {
|
name: {
|
||||||
first: 'George',
|
first: 'Andy',
|
||||||
last: 'Clooney',
|
last: 'Warhol',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
roles: ['admin'],
|
roles: ['admin'],
|
||||||
|
data(userId) {
|
||||||
|
return documentsSeed(userId);
|
||||||
|
},
|
||||||
}],
|
}],
|
||||||
});
|
modelCount: 5,
|
||||||
|
|
||||||
seeder(Documents, {
|
|
||||||
environments: ['development', 'staging'],
|
|
||||||
wipe: true,
|
|
||||||
min: 10,
|
|
||||||
model(index, faker) {
|
model(index, faker) {
|
||||||
const owner = Meteor.users.findOne({ 'emails.address': 'admin@admin.com' })._id;
|
const userCount = index + 1;
|
||||||
const documentNumber = index + 1;
|
|
||||||
return {
|
return {
|
||||||
owner,
|
email: `user+${userCount}@test.com`,
|
||||||
title: `${faker.lorem.words(5)} #${documentNumber}`,
|
password: 'password',
|
||||||
body: `This is the body of example document #${documentNumber}.`,
|
profile: {
|
||||||
|
name: {
|
||||||
|
first: faker.name.firstName(),
|
||||||
|
last: faker.name.lastName(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
roles: ['user'],
|
||||||
|
data(userId) {
|
||||||
|
return documentsSeed(userId);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@cleverbeagle/dates": "^0.2.0",
|
"@cleverbeagle/dates": "^0.2.0",
|
||||||
"@cleverbeagle/seeder": "^0.3.0",
|
"@cleverbeagle/seeder": "^1.1.0",
|
||||||
"babel-runtime": "^6.20.0",
|
"babel-runtime": "^6.20.0",
|
||||||
"bcrypt": "^1.0.2",
|
"bcrypt": "^1.0.2",
|
||||||
"jquery": "^2.2.4",
|
"jquery": "^2.2.4",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue