Newer
Older
factory = {
id : {
current : 0,
next : function(){
return factory.id.current += 1
}
},
guid : function(){
return 'omGUID' + this.id.next()
},
like : function(overrides){
var defaultAttrs = {
"created_at" : "2012-01-04T00:55:30Z",
"author" : this.author(),
"guid" : this.guid(),
"id" : this.id.next()
}
return _.extend(defaultAttrs, overrides)
},
userAttrs : function(overrides){
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
var id = this.id.next()
var defaultAttrs = {
"name":"Awesome User" + id,
"id": id,
"avatar":{
"large":"http://localhost:3000/images/user/uma.jpg",
"medium":"http://localhost:3000/images/user/uma.jpg",
"small":"http://localhost:3000/images/user/uma.jpg"}
}
return _.extend(defaultAttrs, overrides)
},
post : function(overrides) {
var defaultAttrs = {
"provider_display_name" : null,
"created_at" : "2012-01-03T19:53:13Z",
"last_three_comments" : null,
"public" : false,
"guid" : this.guid(),
"image_url" : null,
"author" : this.author(),
"o_embed_cache" : null,
"photos" : [],
"text" : "jasmine is bomb",
"reshares_count" : 0,
"id" : this.id.next(),
"object_url" : null,
"root" : null,
"post_type" : "StatusMessage",
"likes_count" : 0,
"comments_count" : 0,
"photos_count" : 0
}
return new app.models.Post(_.extend(defaultAttrs, overrides))
}
}
factory.author = factory.userAttrs