-
Notifications
You must be signed in to change notification settings - Fork 3
/
testing.js
139 lines (121 loc) · 4.26 KB
/
testing.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
models = require('./models'),
Game = models.Game,
Team = models.Team,
User = models.User,
Comment = models.Comment;
exports.getDebug = function(req,res){
res.sendfile(__dirname + '/public/debug.html');
}
exports.createFixtures = function(){
User.find({where:{username: 'jpotts18'}})
.success(function(user){
if(user){
console.log('Database is already built');
}
else{
generateFixtures();
}
})
.error(function(error){
console.log(error);
});
}
function generateFixtures(){
console.log('+++++++++++++++++++++++++++++++++++++++');
console.log('GENERATING FIXTURES');
console.log('+++++++++++++++++++++++++++++++++++++++');
// generating data
generateUsers();
generatePages();
generateBlocks();
generateComments();
// generateGames();
// generateTeams();
// generateComments();
}
function generatePages(){
var pages = [];
pages.push({ slug : 'page-1', isDraft : false, isPublished : true , title : 'Home'});
pages.push({ slug : 'page-2', isDraft : true, isPublished : true , title : 'About'});
for (var i = 0; i < pages.length; i++) {
Page.build(pages[i])
.save()
.success(function(){
})
.error(function(){
});
};
}
function generateBlocks(){
var blocks = [];
blocks.push({ tag : 'h1', content : 'This is Page one Header one', isMobile : true, pageId : 1 });
blocks.push({ tag : 'h2', content : 'This is Page one Header two', isMobile : true, pageId : 1 });
blocks.push({ tag : 'p' , content : 'This is a p one for Page one text', isMobile : true, pageId : 1 });
blocks.push({ tag : 'p' , content : 'This is a p two for Page one text', isMobile : true, pageId : 1 });
blocks.push({ tag : 'p' , content : 'This is a p three for Page one text', isMobile : true, pageId : 1 });
blocks.push({ tag : 'hr', content : null , isMobile : false, pageId : 1});
blocks.push({ tag : 'h1', content : 'This is Page two Header one', isMobile : true, pageId : 2 });
blocks.push({ tag : 'h2', content : 'This is Page two Header two', isMobile : true, pageId : 2 });
blocks.push({ tag : 'p' , content : 'This is a p one for Page two text', isMobile : true, pageId : 2 });
blocks.push({ tag : 'p' , content : 'This is a p two for Page two text', isMobile : true, pageId : 2 });
blocks.push({ tag : 'p' , content : 'This is a p three for Page two text', isMobile : true, pageId : 2 });
for (var i = 0; i < blocks.length; i++) {
Block.build(blocks[i])
.save()
.success(function(block){
})
.error(function(){
});
};
}
function generateComments(){
var comments = [];
comments.push({ title : 'New Comment 1', content : 'Great article 1', author : 'jpotts18', email : '[email protected]', pageId : 1 });
comments.push({ title : 'New Comment 2', content : 'Great article 2', author : 'jpotts18', email : '[email protected]', pageId : 1 });
comments.push({ title : 'New Comment 3', content : 'Great article 3', author : 'jpotts18', email : '[email protected]', pageId : 1 });
comments.push({ title : 'New Comment 4', content : 'Great article 4 for page 2', author : 'jpotts18', email : '[email protected]', pageId : 2 });
comments.push({ title : 'New Comment 5', content : 'Great article 5 for page 2', author : 'jpotts18', email : '[email protected]', pageId : 2 });
for (var i = 0; i < comments.length; i++) {
Comment.build(comments[i])
.save()
.success(function(comment){
})
.error(function(){
});
};
}
function generateUsers(){
var users = [];
users.push({
first : 'Jeff',
last : 'Potter',
username : 'jpotts18',
password : 'sha1$5206e6e3$1$cddd0560dbcb5a07f73b851ccc0c507bd6d51197',
email : '[email protected]',
apiKey : '3e9ca43b-16f8-5089-5b2b-8a775f130275'
});
users.push({
first : 'Nick',
last : 'Walter',
username : 'nwalter',
password : 'sha1$aee25eb4$1$d5c4fbbafcfe2d10dbe71f2f289a98c5bfd1f8f6',
email : '[email protected]',
apiKey : '702b0a4c-2042-a1e7-51eb-caf84285a4ee'
});
users.push({
first : 'Mike',
last : 'Tingey',
username : 'mtingey',
password : 'sha1$599a25e5$1$e5cd1d35c5c30e655f1efa857bf4e1bce74b9e0c',
email : '[email protected]',
apiKey : '0711989c-c2f2-d77c-5ca7-eb742e076dc4'
});
for (var i = 0; i < users.length; i++) {
User.build(users[i])
.save()
.success(function(user){
})
.error(function(){
});
}
}