-
-
Notifications
You must be signed in to change notification settings - Fork 137
/
user.js
71 lines (70 loc) · 1.61 KB
/
user.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
import FactoryGuy from 'ember-data-factory-guy';
FactoryGuy.define('user', {
sequences: {
name: (num) => `User${num}`,
},
// default values for 'user' attributes
default: {
style: 'normal',
name: FactoryGuy.generate('name'),
},
// named 'user' type with custom attributes
admin: {
name: 'Admin',
style: 'super',
},
// 'bob' user with it's custom attributes
bob: {
name: 'Bob',
style: 'boblike',
},
// can accomplish this with traits ( see 'with_projects' trait below )
user_with_projects: {
projects: FactoryGuy.hasMany('project', 2),
},
traits: {
silly: {
style: 'silly',
},
whacky: {
style: 'whacky',
},
boblike: {
name: 'Bob',
style: 'boblike',
},
adminlike: {
name: 'Admin',
style: 'super',
},
with_company: {
company: {},
},
with_projects: {
projects: FactoryGuy.hasMany('project', 2),
},
with_projects_splat: {
projects: FactoryGuy.hasMany('project', 'big', 'small', {
title: 'Cool Project',
}),
},
with_hats: {
hats: FactoryGuy.hasMany('big-hat', 2),
},
with_hats_belonging_to_user: {
hats: FactoryGuy.hasMany('big-hat', 2, 'belonging_to_user'),
},
with_hats_belonging_to_outfit: {
hats: FactoryGuy.hasMany('big-hat', 2, 'belonging_to_outfit'),
},
companyLink: (f) => {
f.links = Object.assign(f.links, { company: `/users/${f.id}/company` });
},
propertiesLink: (f) => {
f.links = Object.assign(
{ properties: `/users/${f.id}/properties` },
f.links
);
},
},
});