ember-data-factory-guy 0.6.3 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +25 -0
- data/bower.json +4 -4
- data/dist/ember-data-factory-guy.js +13 -183
- data/dist/ember-data-factory-guy.min.js +1 -1
- data/dist/factory_guy_has_many.js +11 -10
- data/ember-data-factory-guy.gemspec +1 -1
- data/package.json +1 -1
- data/src/factory_guy_test_mixin.js +10 -3
- data/src/has_many.js +11 -10
- data/src/store.js +3 -180
- data/tests/active_model_adapter_factory_test.js +36 -31
- data/tests/factory_guy_test_mixin_test.js +19 -0
- data/tests/fixture_adapter_factory_test.js +33 -43
- data/tests/rest_adapter_factory_test.js +47 -43
- data/vendor/assets/javascripts/ember_data_factory_guy.js +14 -183
- data/vendor/assets/javascripts/factory_guy_has_many.js +11 -10
- metadata +2 -2
@@ -54,7 +54,7 @@ asyncTest("creates records in the store", function() {
|
|
54
54
|
var user = store.makeFixture('user');
|
55
55
|
|
56
56
|
store.find('user', user.id).then ( function(store_user) {
|
57
|
-
|
57
|
+
equal(store_user, user);
|
58
58
|
start()
|
59
59
|
});
|
60
60
|
});
|
@@ -69,7 +69,8 @@ test("handles camelCase attributes", function() {
|
|
69
69
|
test("when hasMany associations assigned, belongTo parent is assigned", function() {
|
70
70
|
var project = store.makeFixture('project');
|
71
71
|
var user = store.makeFixture('user', {projects: [project]})
|
72
|
-
|
72
|
+
|
73
|
+
equal(project.get('user'), user);
|
73
74
|
});
|
74
75
|
|
75
76
|
|
@@ -78,7 +79,7 @@ asyncTest("when asnyc hasMany associations assigned, belongTo parent is assigned
|
|
78
79
|
var company = store.makeFixture('company', {users: [user]});
|
79
80
|
|
80
81
|
user.get('company').then(function(c){
|
81
|
-
|
82
|
+
equal(c, company);
|
82
83
|
start();
|
83
84
|
})
|
84
85
|
});
|
@@ -89,9 +90,9 @@ test("when polymorphic hasMany associations are assigned, belongTo parent is ass
|
|
89
90
|
var sh = store.makeFixture('small_hat');
|
90
91
|
var user = store.makeFixture('user', {hats: [bh, sh]})
|
91
92
|
|
92
|
-
equal(user.get('hats.length'), 2);
|
93
|
-
ok(user.get('hats.firstObject') instanceof BigHat)
|
94
|
-
ok(user.get('hats.lastObject') instanceof SmallHat)
|
93
|
+
equal(user.get('hats.members.list.length'), 2);
|
94
|
+
ok(user.get('hats.manyArray.firstObject') instanceof BigHat)
|
95
|
+
ok(user.get('hats.manyArray.lastObject') instanceof SmallHat)
|
95
96
|
// sets the belongTo user association
|
96
97
|
ok(bh.get('user') == user)
|
97
98
|
ok(sh.get('user') == user)
|
@@ -101,14 +102,16 @@ test("when polymorphic hasMany associations are assigned, belongTo parent is ass
|
|
101
102
|
test("when hasMany associations are assigned, belongsTo parent is assigned using inverse", function() {
|
102
103
|
var project = store.makeFixture('project');
|
103
104
|
var project2 = store.makeFixture('project', {children: [project]});
|
104
|
-
|
105
|
+
|
106
|
+
equal(project.get('parent'), project2);
|
105
107
|
});
|
106
108
|
|
107
109
|
|
108
110
|
test("when hasMany associations are assigned, belongsTo parent is assigned using actual belongsTo name", function() {
|
109
111
|
var silk = store.makeFixture('silk');
|
110
112
|
var bh = store.makeFixture('big_hat', {materials: [silk]});
|
111
|
-
|
113
|
+
|
114
|
+
equal(silk.get('hat'), bh)
|
112
115
|
});
|
113
116
|
|
114
117
|
|
@@ -117,9 +120,9 @@ test("when belongTo parent is assigned, parent adds to hasMany records", functio
|
|
117
120
|
var project1 = store.makeFixture('project', {user: user});
|
118
121
|
var project2 = store.makeFixture('project', {user: user});
|
119
122
|
|
120
|
-
equal(user.get('projects.length'), 2);
|
121
|
-
|
122
|
-
|
123
|
+
equal(user.get('projects.members.list.length'), 2);
|
124
|
+
equal(user.get('projects.manyArray.firstObject'), project1);
|
125
|
+
equal(user.get('projects.manyArray.lastObject'), project2);
|
123
126
|
});
|
124
127
|
|
125
128
|
|
@@ -128,9 +131,9 @@ test("when belongTo parent is assigned, parent adds to polymorphic hasMany recor
|
|
128
131
|
store.makeFixture('big_hat', {user: user});
|
129
132
|
store.makeFixture('small_hat', {user: user});
|
130
133
|
|
131
|
-
equal(user.get('hats.length'), 2);
|
132
|
-
ok(user.get('hats.firstObject') instanceof BigHat)
|
133
|
-
ok(user.get('hats.lastObject') instanceof SmallHat)
|
134
|
+
equal(user.get('hats.members.list.length'), 2);
|
135
|
+
ok(user.get('hats.manyArray.firstObject') instanceof BigHat)
|
136
|
+
ok(user.get('hats.manyArray.lastObject') instanceof SmallHat)
|
134
137
|
});
|
135
138
|
|
136
139
|
|
@@ -139,9 +142,9 @@ asyncTest("when async hasMany relationship is assigned, model relationship is sy
|
|
139
142
|
var user1 = store.makeFixture('user', {properties: [property]});
|
140
143
|
var user2 = store.makeFixture('user', {properties: [property]});
|
141
144
|
|
142
|
-
equal(property.get('owners.length'), 2);
|
143
|
-
|
144
|
-
|
145
|
+
equal(property.get('owners.members.list.length'), 2);
|
146
|
+
equal(property.get('owners.manyArray.firstObject'), user1);
|
147
|
+
equal(property.get('owners.manyArray.lastObject'), user2);
|
145
148
|
start();
|
146
149
|
});
|
147
150
|
|
@@ -151,9 +154,9 @@ asyncTest("when async belongsTo parent is assigned, parent adds to hasMany recor
|
|
151
154
|
var user1 = store.makeFixture('user', {company: company});
|
152
155
|
var user2 = store.makeFixture('user', {company: company});
|
153
156
|
|
154
|
-
equal(company.get('users.length'), 2);
|
155
|
-
|
156
|
-
|
157
|
+
equal(company.get('users.members.list.length'), 2);
|
158
|
+
equal(company.get('users.manyArray.firstObject'), user1);
|
159
|
+
equal(company.get('users.manyArray.lastObject'), user2);
|
157
160
|
start();
|
158
161
|
});
|
159
162
|
|
@@ -161,42 +164,44 @@ asyncTest("when async belongsTo parent is assigned, parent adds to hasMany recor
|
|
161
164
|
test("when belongTo parent is assigned, parent adds to hasMany record using inverse", function() {
|
162
165
|
var project = store.makeFixture('project');
|
163
166
|
var project2 = store.makeFixture('project', {parent: project});
|
164
|
-
|
165
|
-
|
167
|
+
|
168
|
+
equal(project.get('children.members.list.length'), 1);
|
169
|
+
equal(project.get('children.manyArray.firstObject'), project2);
|
166
170
|
});
|
167
171
|
|
168
172
|
|
169
173
|
test("when belongTo parent is assigned, parent adds to hasMany record using actual hasMany name", function() {
|
170
174
|
var bh = store.makeFixture('big_hat');
|
171
175
|
var silk = store.makeFixture('silk', {hat: bh});
|
172
|
-
|
176
|
+
|
177
|
+
equal(bh.get('materials.manyArray.firstObject'), silk)
|
173
178
|
});
|
174
179
|
|
175
180
|
|
176
181
|
test("when belongTo parent is assigned, parent adds to belongsTo record", function() {
|
177
182
|
var company = store.makeFixture('company');
|
178
183
|
var profile = store.makeFixture('profile', {company: company});
|
179
|
-
|
184
|
+
equal(company.get('profile'), profile);
|
180
185
|
|
181
186
|
// but guard against a situation where a model can belong to itself
|
182
187
|
// and do not want to set the belongsTo on this case.
|
183
188
|
var hat1 = store.makeFixture('big_hat')
|
184
189
|
var hat2 = store.makeFixture('big_hat', {hat: hat1})
|
185
|
-
|
186
|
-
|
190
|
+
equal(hat1.get('hat'), null);
|
191
|
+
equal(hat2.get('hat'), hat1);
|
187
192
|
});
|
188
193
|
|
189
194
|
|
190
195
|
test("belongsTo associations defined as attributes in fixture", function() {
|
191
196
|
var project = store.makeFixture('project_with_user');
|
192
197
|
equal(project.get('user') instanceof User, true)
|
193
|
-
|
198
|
+
equal(project.get('user.name'), 'User1');
|
194
199
|
|
195
200
|
var project = store.makeFixture('project_with_dude');
|
196
|
-
|
201
|
+
equal(project.get('user.name'), 'Dude');
|
197
202
|
|
198
203
|
var project = store.makeFixture('project_with_admin');
|
199
|
-
|
204
|
+
equal(project.get('user.name'), 'Admin');
|
200
205
|
});
|
201
206
|
|
202
207
|
|
@@ -222,8 +227,8 @@ test("creates records in the store", function() {
|
|
222
227
|
var users = store.makeList('user', 2);
|
223
228
|
|
224
229
|
var storeUsers = store.all('user').get('content');
|
225
|
-
|
226
|
-
|
230
|
+
equal(storeUsers[0], users[0]);
|
231
|
+
equal(storeUsers[1], users[1]);
|
227
232
|
});
|
228
233
|
|
229
234
|
|
@@ -30,3 +30,22 @@ test("#buildURL with namespace and host", function () {
|
|
30
30
|
equal(testHelper.buildURL('project'), 'https://dude.com/api/v1/projects');
|
31
31
|
})
|
32
32
|
|
33
|
+
//asyncTest("#handleFind handles associations", function() {
|
34
|
+
// var projectJSON = FactoryGuy.build('project');
|
35
|
+
// var userJSON = FactoryGuy.build('user', {projects: [projectJSON.id]});
|
36
|
+
// projectJSON.user = userJSON.id
|
37
|
+
//
|
38
|
+
// testHelper.handleSideloadFind('user', userJSON, {projects: [projectJSON]})
|
39
|
+
//
|
40
|
+
// store.find('user', userJSON.id).then(function(user) {
|
41
|
+
// console.log(user.toJSON())
|
42
|
+
// console.log(userJSON)
|
43
|
+
//// console.log(user+'',user.get('projects.firstObject').toJSON())
|
44
|
+
//// console.log(user.get('projects.firstObject.user')+'')
|
45
|
+
//// ok(user.toJSON() == userJSON)
|
46
|
+
// ok(user instanceof User)
|
47
|
+
// ok(user.get('projects.firstObject.user') == user)
|
48
|
+
//// deepEqual(user.get('projects.firstObject').toJSON(), project)
|
49
|
+
// start();
|
50
|
+
// });
|
51
|
+
//});
|
@@ -88,11 +88,9 @@ asyncTest("#makeFixture sets belongsTo on hasMany associations", function () {
|
|
88
88
|
var user = store.makeFixture('user', {projects: [p1]})
|
89
89
|
|
90
90
|
store.find('user', 1).then(function (user) {
|
91
|
-
user.get('projects')
|
92
|
-
|
93
|
-
|
94
|
-
start();
|
95
|
-
})
|
91
|
+
var projects = user.get('projects');
|
92
|
+
equal(projects.members.list.length, 1, "adds hasMany records");
|
93
|
+
start();
|
96
94
|
})
|
97
95
|
})
|
98
96
|
|
@@ -102,11 +100,10 @@ asyncTest("#makeFixture adds record to hasMany association array for which it be
|
|
102
100
|
var projectJson = store.makeFixture('project', {user: userJson});
|
103
101
|
|
104
102
|
store.find('user', userJson.id).then(function (user) {
|
105
|
-
user.get('projects')
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
})
|
103
|
+
var projects = user.get('projects');
|
104
|
+
equal(projects.members.list.length, 1, "adds hasMany records");
|
105
|
+
equal(projects.manyArray.get('firstObject.user'), user, "sets belongsTo record");
|
106
|
+
start();
|
110
107
|
})
|
111
108
|
})
|
112
109
|
|
@@ -115,11 +112,10 @@ asyncTest("#makeFixture handles default belongsTo associations in fixture", func
|
|
115
112
|
equal(User.FIXTURES.length, 1);
|
116
113
|
|
117
114
|
store.find('user', 1).then(function (user) {
|
118
|
-
user.get('projects')
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
})
|
115
|
+
var projects = user.get('projects');
|
116
|
+
equal(projects.members.list.length, 1, "adds hasMany records");
|
117
|
+
equal(projects.manyArray.get('firstObject.user.id'), 1, "sets belongsTo record");
|
118
|
+
start();
|
123
119
|
})
|
124
120
|
// TODO.. have to make belongsTo async for fixture adapter
|
125
121
|
// to get this to work
|
@@ -134,25 +130,24 @@ asyncTest("#makeFixture handles default belongsTo associations in fixture", func
|
|
134
130
|
})
|
135
131
|
|
136
132
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
//})
|
133
|
+
asyncTest("#createRecord adds belongsTo association to records it hasMany of", function () {
|
134
|
+
var user = store.makeFixture('user');
|
135
|
+
|
136
|
+
store.find('user', user.id).then(function (user) {
|
137
|
+
|
138
|
+
var projectJson = {title: 'project', user: user};
|
139
|
+
|
140
|
+
store.createRecord('project', projectJson).save()
|
141
|
+
.then(function (project) {
|
142
|
+
return Ember.RSVP.all([project.get('user'), user.get('projects')]);
|
143
|
+
}).then(function (promises) {
|
144
|
+
var projectUser = promises[0], projects = promises[1];
|
145
|
+
equal(projectUser, user);
|
146
|
+
equal(projects.members.list.length, 1);
|
147
|
+
start();
|
148
|
+
});
|
149
|
+
})
|
150
|
+
})
|
156
151
|
|
157
152
|
asyncTest("#createRecord can work for one-to-none associations", function () {
|
158
153
|
var user = store.makeFixture('user');
|
@@ -179,14 +174,9 @@ asyncTest("#createRecord adds hasMany association to records it hasMany of ", fu
|
|
179
174
|
var propertyJson = {name: 'beach front property'};
|
180
175
|
|
181
176
|
var property = store.createRecord('property', propertyJson);
|
182
|
-
property.get('owners')
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
return property.get('owners');
|
187
|
-
}).then(function (users) {
|
188
|
-
equal(users.get('length'), usersJson.length);
|
189
|
-
start();
|
190
|
-
});
|
177
|
+
var owners = property.get('owners')
|
178
|
+
owners.manyArray.addObjects(users);
|
179
|
+
equal(users.get('length'), usersJson.length);
|
180
|
+
start();
|
191
181
|
})
|
192
182
|
})
|
@@ -22,8 +22,8 @@ test("#resetModels clears the store of models, and resets the model definition",
|
|
22
22
|
|
23
23
|
FactoryGuy.resetModels(store);
|
24
24
|
|
25
|
-
equal(store.all('user').get('content.length'),0)
|
26
|
-
equal(store.all('project').get('content.length'),0)
|
25
|
+
equal(store.all('user').get('content.length'), 0)
|
26
|
+
equal(store.all('project').get('content.length'), 0)
|
27
27
|
|
28
28
|
for (model in FactoryGuy.modelDefinitions) {
|
29
29
|
var definition = FactoryGuy.modelDefinitions[model];
|
@@ -53,8 +53,8 @@ test("creates DS.Model instances", function() {
|
|
53
53
|
asyncTest("creates records in the store", function() {
|
54
54
|
var user = store.makeFixture('user');
|
55
55
|
|
56
|
-
store.find('user', user.id).then
|
57
|
-
|
56
|
+
store.find('user', user.id).then( function(store_user) {
|
57
|
+
equal(store_user, user);
|
58
58
|
start()
|
59
59
|
});
|
60
60
|
});
|
@@ -64,7 +64,7 @@ test("when hasMany associations assigned, belongTo parent is assigned", function
|
|
64
64
|
var project = store.makeFixture('project');
|
65
65
|
var user = store.makeFixture('user', {projects: [project]})
|
66
66
|
|
67
|
-
|
67
|
+
equal(project.get('user'), user);
|
68
68
|
});
|
69
69
|
|
70
70
|
|
@@ -73,7 +73,7 @@ asyncTest("when asnyc hasMany associations assigned, belongTo parent is assigned
|
|
73
73
|
var company = store.makeFixture('company', {users: [user]});
|
74
74
|
|
75
75
|
user.get('company').then(function(c){
|
76
|
-
|
76
|
+
equal(c, company);
|
77
77
|
start();
|
78
78
|
})
|
79
79
|
});
|
@@ -82,28 +82,30 @@ asyncTest("when asnyc hasMany associations assigned, belongTo parent is assigned
|
|
82
82
|
test("when polymorphic hasMany associations are assigned, belongTo parent is assigned", function() {
|
83
83
|
var bh = store.makeFixture('big_hat');
|
84
84
|
var sh = store.makeFixture('small_hat');
|
85
|
-
var user = store.makeFixture('user', {hats: [bh, sh]})
|
85
|
+
var user = store.makeFixture('user', {hats: [bh, sh]});
|
86
86
|
|
87
|
-
equal(user.get('hats.length'), 2);
|
88
|
-
ok(user.get('hats.firstObject') instanceof BigHat)
|
89
|
-
ok(user.get('hats.lastObject') instanceof SmallHat)
|
87
|
+
equal(user.get('hats.members.list.length'), 2);
|
88
|
+
ok(user.get('hats.manyArray.firstObject') instanceof BigHat)
|
89
|
+
ok(user.get('hats.manyArray.lastObject') instanceof SmallHat)
|
90
90
|
// sets the belongTo user association
|
91
|
-
|
92
|
-
|
91
|
+
equal(bh.get('user'), user)
|
92
|
+
equal(sh.get('user'), user)
|
93
93
|
});
|
94
94
|
|
95
95
|
|
96
96
|
test("when hasMany associations are assigned, belongsTo parent is assigned using inverse", function() {
|
97
97
|
var project = store.makeFixture('project');
|
98
98
|
var project2 = store.makeFixture('project', {children: [project]});
|
99
|
-
|
99
|
+
|
100
|
+
equal(project.get('parent'), project2);
|
100
101
|
});
|
101
102
|
|
102
103
|
|
103
104
|
test("when hasMany associations are assigned, belongsTo parent is assigned using actual belongsTo name", function() {
|
104
105
|
var silk = store.makeFixture('silk');
|
105
106
|
var bh = store.makeFixture('big_hat', {materials: [silk]});
|
106
|
-
|
107
|
+
|
108
|
+
equal(silk.get('hat'), bh)
|
107
109
|
});
|
108
110
|
|
109
111
|
|
@@ -112,9 +114,9 @@ test("when belongTo parent is assigned, parent adds to hasMany records", functio
|
|
112
114
|
var project1 = store.makeFixture('project', {user: user});
|
113
115
|
var project2 = store.makeFixture('project', {user: user});
|
114
116
|
|
115
|
-
equal(user.get('projects.length'), 2);
|
116
|
-
|
117
|
-
|
117
|
+
equal(user.get('projects.members.list.length'), 2);
|
118
|
+
equal(user.get('projects.manyArray.firstObject'), project1);
|
119
|
+
equal(user.get('projects.manyArray.lastObject'), project2);
|
118
120
|
});
|
119
121
|
|
120
122
|
|
@@ -123,9 +125,9 @@ test("when belongTo parent is assigned, parent adds to polymorphic hasMany recor
|
|
123
125
|
store.makeFixture('big_hat', {user: user});
|
124
126
|
store.makeFixture('small_hat', {user: user});
|
125
127
|
|
126
|
-
equal(user.get('hats.length'), 2);
|
127
|
-
ok(user.get('hats.firstObject') instanceof BigHat)
|
128
|
-
ok(user.get('hats.lastObject') instanceof SmallHat)
|
128
|
+
equal(user.get('hats.members.list.length'), 2);
|
129
|
+
ok(user.get('hats.manyArray.firstObject') instanceof BigHat)
|
130
|
+
ok(user.get('hats.manyArray.lastObject') instanceof SmallHat)
|
129
131
|
});
|
130
132
|
|
131
133
|
|
@@ -134,9 +136,9 @@ asyncTest("when async hasMany relationship is assigned, model relationship is sy
|
|
134
136
|
var user1 = store.makeFixture('user', {properties: [property]});
|
135
137
|
var user2 = store.makeFixture('user', {properties: [property]});
|
136
138
|
|
137
|
-
equal(property.get('owners.length'), 2);
|
138
|
-
deepEqual(property.get('owners.firstObject')
|
139
|
-
deepEqual(property.get('owners.lastObject')
|
139
|
+
equal(property.get('owners.members.list.length'), 2);
|
140
|
+
deepEqual(property.get('owners.manyArray.firstObject'), user1);
|
141
|
+
deepEqual(property.get('owners.manyArray.lastObject'), user2);
|
140
142
|
start();
|
141
143
|
});
|
142
144
|
|
@@ -146,9 +148,9 @@ asyncTest("when async belongsTo parent is assigned, parent adds to hasMany recor
|
|
146
148
|
var user2 = store.makeFixture('user');
|
147
149
|
var company = store.makeFixture('company', {users: [user1, user2]});
|
148
150
|
|
149
|
-
equal(company.get('users.length'), 2);
|
150
|
-
|
151
|
-
|
151
|
+
equal(company.get('users.members.list.length'), 2);
|
152
|
+
equal(company.get('users.manyArray.firstObject'), user1);
|
153
|
+
equal(company.get('users.manyArray.lastObject'), user2);
|
152
154
|
start();
|
153
155
|
});
|
154
156
|
|
@@ -156,57 +158,59 @@ asyncTest("when async belongsTo parent is assigned, parent adds to hasMany recor
|
|
156
158
|
test("when belongTo parent is assigned, parent adds to hasMany record using inverse", function() {
|
157
159
|
var project = store.makeFixture('project');
|
158
160
|
var project2 = store.makeFixture('project', {parent: project});
|
159
|
-
|
160
|
-
|
161
|
+
|
162
|
+
equal(project.get('children.members.list.length'), 1);
|
163
|
+
equal(project.get('children.manyArray.firstObject'), project2);
|
161
164
|
});
|
162
165
|
|
163
166
|
|
164
167
|
test("when belongTo parent is assigned, parent adds to hasMany record using actual hasMany name", function() {
|
165
168
|
var bh = store.makeFixture('big_hat');
|
166
169
|
var silk = store.makeFixture('silk', {hat: bh});
|
167
|
-
|
170
|
+
|
171
|
+
equal(bh.get('materials.manyArray.firstObject'), silk)
|
168
172
|
});
|
169
173
|
|
170
174
|
|
171
175
|
test("when belongTo parent is assigned, parent adds to belongsTo record", function() {
|
172
176
|
var company = store.makeFixture('company');
|
173
177
|
var profile = store.makeFixture('profile', {company: company});
|
174
|
-
|
178
|
+
equal(company.get('profile'), profile);
|
175
179
|
|
176
180
|
// but guard against a situation where a model can belong to itself
|
177
181
|
// and do not want to set the belongsTo on this case.
|
178
182
|
var hat1 = store.makeFixture('big_hat')
|
179
183
|
var hat2 = store.makeFixture('big_hat', {hat: hat1})
|
180
|
-
|
181
|
-
|
184
|
+
equal(hat1.get('hat'), null);
|
185
|
+
equal(hat2.get('hat'), hat1);
|
182
186
|
});
|
183
187
|
|
184
188
|
|
185
189
|
test("belongsTo associations defined as attributes in fixture", function() {
|
186
190
|
var project = store.makeFixture('project_with_user');
|
187
191
|
equal(project.get('user') instanceof User, true)
|
188
|
-
|
192
|
+
equal(project.get('user.name'), 'User1');
|
189
193
|
|
190
194
|
var project = store.makeFixture('project_with_dude');
|
191
|
-
|
195
|
+
equal(project.get('user.name'), 'Dude');
|
192
196
|
|
193
197
|
var project = store.makeFixture('project_with_admin');
|
194
|
-
|
198
|
+
equal(project.get('user.name'), 'Admin');
|
195
199
|
});
|
196
200
|
|
197
201
|
|
198
202
|
test("hasMany associations defined as attributes in fixture", function() {
|
199
203
|
var user = store.makeFixture('user_with_projects');
|
200
|
-
equal(user.get('projects.length'), 2)
|
201
|
-
equal(user.get('projects.firstObject.user'), user)
|
202
|
-
equal(user.get('projects.lastObject.user'), user)
|
204
|
+
equal(user.get('projects.members.list.length'), 2)
|
205
|
+
equal(user.get('projects.manyArray.firstObject.user'), user)
|
206
|
+
equal(user.get('projects.manyArray.lastObject.user'), user)
|
203
207
|
})
|
204
208
|
|
205
209
|
test("hasMany associations defined with traits", function() {
|
206
210
|
var user = store.makeFixture('user', 'with_projects');
|
207
|
-
equal(user.get('projects.length'), 2)
|
208
|
-
equal(user.get('projects.firstObject.user'), user)
|
209
|
-
equal(user.get('projects.lastObject.user'), user)
|
211
|
+
equal(user.get('projects.members.list.length'), 2)
|
212
|
+
equal(user.get('projects.manyArray.firstObject.user'), user)
|
213
|
+
equal(user.get('projects.manyArray.lastObject.user'), user)
|
210
214
|
})
|
211
215
|
|
212
216
|
|
@@ -232,6 +236,6 @@ test("creates records in the store", function() {
|
|
232
236
|
var users = store.makeList('user', 2);
|
233
237
|
|
234
238
|
var storeUsers = store.all('user').get('content');
|
235
|
-
|
236
|
-
|
239
|
+
equal(storeUsers[0], users[0]);
|
240
|
+
equal(storeUsers[1], users[1]);
|
237
241
|
});
|