ember-data-factory-guy 0.9.8 → 0.9.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0650e66ee950da634303e3cc9ff5a32a6f9a5c5b
4
- data.tar.gz: da9d920628d9c30787d4c4ffcd53fa6285b6ed33
3
+ metadata.gz: 6e4648a11858529bb5355b440b02b0ca24a7f8bf
4
+ data.tar.gz: 423900ef7416682118d3c180677af2f8fcf77468
5
5
  SHA512:
6
- metadata.gz: 01cf3a560b474549974245e618bbd235ab81719420672a24ae28b333643f5cfa009b2522130e252e56508541b549f711baab63d601c6662296e29e975c5b302b
7
- data.tar.gz: 94a67fcb425895b84bb93fc82393d036ba206749bb29a0e482591fcd677e87fd0a81087d21a300cd3ce87c6daf4b30899bba1bc484702b9b5686f2868e4ea98d
6
+ metadata.gz: 611b82bee5d7602ed3d0294fe0d4cc1e66061ab0c98f103de3250a9be83b9e082652505dccd4c6b5bf33ee45f3008b4c9a62bac5f131741f4ab95b9a85c7d970
7
+ data.tar.gz: 9efc3f1265f49dc5ebec18410d018e67077132be6298b9aaa547acab83fe839c70d961c6771d81e6bab0c97cd3711c65ed6ef01a86d9b477c26290414dd67c21
data/README.md CHANGED
@@ -14,12 +14,10 @@ of ember-data-factory-guy.
14
14
  - 0.6.4 -> ember-data-1.0.0-beta.8 and under
15
15
  - 0.7.1.1 -> ember-data-1.0.0-beta.10
16
16
  - 0.8.6 -> ember-data-1.0.0-beta.11
17
- - 0.9.7 -> ember-data-1.0.0-beta.12
17
+ - 0.9.8 -> ember-data-1.0.0-beta.12
18
+ - 0.9.9 -> ember-data-1.0.0-beta.15
18
19
 
19
- **Waiting for ember-data-1.0.0-beta.15 to make upgrade release, since there are a few issues with
20
- ember-data-1.0.0-beta.14.1 that make it difficult to use**
21
-
22
- **Support for fixture adapter is back in business as of version 0.9.3**
20
+ **Support for fixture adapter is working for versions 0.9.3 -> 0.9.8**
23
21
 
24
22
  *Version 0.9.0 and up deprecates explicit call to store.makeFixture in your tests, in favor
25
23
  of using the FactoryGuy.make or testHelper.make function from FactoryGuyTestHelperMixin instead.
@@ -46,7 +44,7 @@ gem 'ember-data-factory-guy', group: test
46
44
  or for particular version:
47
45
 
48
46
  ```ruby
49
- gem 'ember-data-factory-guy', '0.9.7', group: test
47
+ gem 'ember-data-factory-guy', '0.9.9', group: test
50
48
  ```
51
49
 
52
50
  then:
@@ -81,7 +79,7 @@ or for particular version:
81
79
  "dependencies": {
82
80
  "foo-dependency": "latest",
83
81
  "other-foo-dependency": "latest",
84
- "ember-data-factory-guy": "0.9.7"
82
+ "ember-data-factory-guy": "0.9.9"
85
83
  }
86
84
  ```
87
85
 
@@ -713,6 +711,8 @@ tests run as shown in the previous section (Using FactoryGuyTestMixin)**
713
711
  - succeed - flag to indicate if the request should succeed ( default is true )
714
712
  - this style will eventually be deprecated
715
713
 
714
+ - need to wrap tests using handleCreate with: Ember.run.function() { 'your test' })
715
+
716
716
  **Note**
717
717
 
718
718
  *Any attributes in match will be added to the response json automatically,
@@ -816,6 +816,7 @@ chainable methods, or options hash.
816
816
  ##### handleUpdate
817
817
  - handleUpdate(model)
818
818
  - handleUpdate(modelType, id)
819
+ - need to wrap tests using handleUpdate with: Ember.run.function() { 'your test' })
819
820
 
820
821
  *success case is the default*
821
822
 
@@ -850,6 +851,7 @@ chainable methods, or options hash.
850
851
 
851
852
 
852
853
  ##### handleDelete
854
+ - need to wrap tests using handleDelete with: Ember.run.function() { 'your test' })
853
855
 
854
856
  *success case is the default*
855
857
 
@@ -900,32 +902,34 @@ module('User View', {
900
902
  });
901
903
 
902
904
  test("Creates new project", function() {
903
- andThen(function() {
904
- var newProjectName = "Gonzo Project"
905
-
906
- click('.add-div div:contains(New Project)')
907
- fillIn('.add-project input', newProjectName)
908
-
909
- // Remember, this is for handling an exact match, if you did not care about
910
- // matching attributes, you could just do: viewHelper.handleCreate('project')
911
- viewHelper.handleCreate('project', {match:{name: newProjectName, user:user}})
912
-
913
- /**
914
- Let's say that clicking this '.add-project .link', triggers action in the view to
915
- create project record and looks something like this:
916
-
917
- actions: {
918
- addProject: function (user) {
919
- var name = this.$('.add-project input').val();
920
- var store = this.get('controller.store');
921
- store.createRecord('project', {name: name, user: user}).save();
922
- }
923
-
924
- */
925
- click('.add-project .link')
926
-
927
- var newProjectDiv = find('.project:contains('+newProjectName+')')
928
- equal(newProjectDiv[0] != undefined, true)
905
+ Em.run(function() {
906
+ andThen(function() {
907
+ var newProjectName = "Gonzo Project"
908
+
909
+ click('.add-div div:contains(New Project)')
910
+ fillIn('.add-project input', newProjectName)
911
+
912
+ // Remember, this is for handling an exact match, if you did not care about
913
+ // matching attributes, you could just do: viewHelper.handleCreate('project')
914
+ viewHelper.handleCreate('project', {match:{name: newProjectName, user:user}})
915
+
916
+ /**
917
+ Let's say that clicking this '.add-project .link', triggers action in the view to
918
+ create project record and looks something like this:
919
+
920
+ actions: {
921
+ addProject: function (user) {
922
+ var name = this.$('.add-project input').val();
923
+ var store = this.get('controller.store');
924
+ store.createRecord('project', {name: name, user: user}).save();
925
+ }
926
+
927
+ */
928
+ click('.add-project .link')
929
+
930
+ var newProjectDiv = find('.project:contains('+newProjectName+')')
931
+ equal(newProjectDiv[0] != undefined, true)
932
+ })
929
933
  })
930
934
  })
931
935
 
data/bower.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-data-factory-guy",
3
- "version": "0.9.8",
3
+ "version": "0.9.9",
4
4
  "authors": [
5
5
  "Daniel Sudol <dansudol@yahoo.com>",
6
6
  "Opak Alex <opak.alexandr@gmail.com>"
@@ -15,7 +15,7 @@
15
15
  ],
16
16
  "license": "MIT",
17
17
  "dependencies": {
18
- "ember-data": "1.0.0-beta.12",
18
+ "ember-data": "1.0.0-beta.15",
19
19
  "jquery-mockjax": "latest"
20
20
  },
21
21
  "ignore": [
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-data-factory-guy",
3
- "version": "0.9.8",
3
+ "version": "0.9.9",
4
4
  "authors": [
5
5
  "Daniel Sudol <dansudol@yahoo.com>",
6
6
  "Opak Alex <opak.alexandr@gmail.com>"
@@ -14,24 +14,26 @@ module('FactoryGuy with ActiveModelAdapter', {
14
14
 
15
15
 
16
16
  test("#resetModels clears the store of models, and resets the model definition", function() {
17
- var project = make('project');
18
- var user = make('user', {projects: [project]});
17
+ Em.run(function() {
18
+ var project = make('project');
19
+ var user = make('user', {projects: [project]});
19
20
 
20
- for (model in FactoryGuy.modelDefinitions) {
21
- var definition = FactoryGuy.modelDefinitions[model];
22
- sinon.spy(definition, 'reset');
23
- }
21
+ for (model in FactoryGuy.modelDefinitions) {
22
+ var definition = FactoryGuy.modelDefinitions[model];
23
+ sinon.spy(definition, 'reset');
24
+ }
24
25
 
25
- FactoryGuy.resetModels(store);
26
+ FactoryGuy.resetModels(store);
26
27
 
27
- equal(store.all('user').get('content.length'),0)
28
- equal(store.all('project').get('content.length'),0)
28
+ equal(store.all('user').get('content.length'),0)
29
+ equal(store.all('project').get('content.length'),0)
29
30
 
30
- for (model in FactoryGuy.modelDefinitions) {
31
- var definition = FactoryGuy.modelDefinitions[model];
32
- ok(definition.reset.calledOnce);
33
- definition.reset.restore();
34
- }
31
+ for (model in FactoryGuy.modelDefinitions) {
32
+ var definition = FactoryGuy.modelDefinitions[model];
33
+ ok(definition.reset.calledOnce);
34
+ definition.reset.restore();
35
+ }
36
+ });
35
37
  });
36
38
 
37
39
 
@@ -31,26 +31,30 @@ module('FactoryGuyTestMixin (using mockjax) with DS.RESTAdapter', {
31
31
  make = function() {return FactoryGuy.make.apply(FactoryGuy,arguments)}
32
32
  },
33
33
  teardown: function () {
34
- testHelper.teardown();
34
+ Em.run(function() {
35
+ testHelper.teardown();
36
+ });
35
37
  }
36
38
  });
37
39
 
38
40
  /////// handleCreate //////////
39
41
 
40
42
  asyncTest("#handleCreate the basic", function() {
41
- var customDescription = "special description"
42
-
43
- testHelper.handleCreate('profile', {
44
- match: {description: customDescription}
45
- })
46
- ok(store.all('profile').get('content.length') == 0)
47
- store.createRecord('profile', {
48
- description: customDescription
49
- }).save().then(function(profile) {
50
- ok(store.all('profile').get('content.length') == 1, 'No extra records created')
51
- ok(profile instanceof Profile, 'Creates the correct type of record')
52
- ok(profile.get('description') == customDescription, 'Passes along the match attributes')
53
- start();
43
+ Em.run(function() {
44
+ var customDescription = "special description"
45
+
46
+ testHelper.handleCreate('profile', {
47
+ match: {description: customDescription}
48
+ })
49
+ ok(store.all('profile').get('content.length') == 0)
50
+ store.createRecord('profile', {
51
+ description: customDescription
52
+ }).save().then(function(profile) {
53
+ ok(store.all('profile').get('content.length') == 1, 'No extra records created')
54
+ ok(profile instanceof Profile, 'Creates the correct type of record')
55
+ ok(profile.get('description') == customDescription, 'Passes along the match attributes')
56
+ start();
57
+ });
54
58
  });
55
59
  });
56
60
 
@@ -175,14 +179,15 @@ asyncTest("#handleFind with a record returns the record", function () {
175
179
  });
176
180
 
177
181
  asyncTest("#handleFind with a record handles reload", function () {
178
- var profile = FactoryGuy.make('profile')
179
- testHelper.handleFind(profile);
182
+ Em.run(function() {
183
+ var profile = FactoryGuy.make('profile')
184
+ testHelper.handleFind(profile);
180
185
 
181
- profile.reload().then(function (profile2) {
182
- ok(profile2.id == profile.id);
183
- start();
186
+ profile.reload().then(function (profile2) {
187
+ ok(profile2.id == profile.id);
188
+ start();
189
+ });
184
190
  });
185
-
186
191
  });
187
192
 
188
193
  asyncTest("#handleFind with options", function () {
@@ -237,7 +242,9 @@ module('FactoryGuyTestMixin (using mockjax) with DS.ActiveModelAdapter', {
237
242
  make = function() {return FactoryGuy.make.apply(FactoryGuy,arguments)}
238
243
  },
239
244
  teardown: function () {
240
- testHelper.teardown();
245
+ Em.run(function() {
246
+ testHelper.teardown();
247
+ });
241
248
  }
242
249
  });
243
250
 
@@ -246,274 +253,311 @@ module('FactoryGuyTestMixin (using mockjax) with DS.ActiveModelAdapter', {
246
253
 
247
254
  /////// with hash of parameters ///////////////////
248
255
  asyncTest("#handleCreate with no specific match", function() {
249
- testHelper.handleCreate('profile');
256
+ Em.run(function() {
257
+ testHelper.handleCreate('profile');
250
258
 
251
- store.createRecord('profile', {description: 'whatever'}).save().then(function(profile) {
252
- ok(profile.id == 1)
253
- ok(profile.get('description') == 'whatever')
254
- start();
259
+ store.createRecord('profile', {description: 'whatever'}).save().then(function(profile) {
260
+ ok(profile.id == 1)
261
+ ok(profile.get('description') == 'whatever')
262
+ start();
263
+ });
255
264
  });
256
265
  });
257
266
 
258
267
  asyncTest("#handleCreate match some attributes", function() {
259
- var customDescription = "special description"
260
- var date = new Date();
261
-
262
- testHelper.handleCreate('profile', {
263
- match: {description: customDescription}
268
+ Em.run(function() {
269
+ var customDescription = "special description"
270
+ var date = new Date();
271
+
272
+ testHelper.handleCreate('profile', {
273
+ match: {description: customDescription}
274
+ })
275
+
276
+ store.createRecord('profile', {
277
+ description: customDescription, created_at: date
278
+ }).save().then(function (profile) {
279
+ ok(profile instanceof Profile)
280
+ ok(profile.id == 1)
281
+ ok(profile.get('description') == customDescription)
282
+ start();
283
+ });
264
284
  })
265
-
266
- store.createRecord('profile', {
267
- description: customDescription, created_at: date
268
- }).save().then(function(profile) {
269
- ok(profile instanceof Profile)
270
- ok(profile.id == 1)
271
- ok(profile.get('description') == customDescription)
272
- start();
273
- });
274
285
  });
275
286
 
276
287
  asyncTest("#handleCreate match all attributes", function() {
277
- var customDescription = "special description"
278
- var date = new Date();
279
-
280
- testHelper.handleCreate('profile', {
281
- match: {description: customDescription, created_at: date}
282
- })
283
-
284
- store.createRecord('profile', {
285
- description: customDescription, created_at: date
286
- }).save().then(function(profile) {
287
- ok(profile instanceof Profile)
288
- ok(profile.id == 1)
289
- ok(profile.get('description') == customDescription)
290
- ok(profile.get('created_at') == date.toString())
291
- start();
288
+ Em.run(function() {
289
+ var customDescription = "special description"
290
+ var date = new Date();
291
+
292
+ testHelper.handleCreate('profile', {
293
+ match: {description: customDescription, created_at: date}
294
+ })
295
+
296
+ store.createRecord('profile', {
297
+ description: customDescription, created_at: date
298
+ }).save().then(function(profile) {
299
+ ok(profile instanceof Profile)
300
+ ok(profile.id == 1)
301
+ ok(profile.get('description') == customDescription)
302
+ ok(profile.get('created_at') == date.toString())
303
+ start();
304
+ });
292
305
  });
293
306
  });
294
307
 
295
308
 
296
309
  asyncTest("#handleCreate returns attributes", function() {
297
- var date = new Date()
310
+ Em.run(function() {
311
+ var date = new Date()
298
312
 
299
- testHelper.handleCreate('profile', {
300
- returns: {created_at: date}
301
- })
313
+ testHelper.handleCreate('profile', {
314
+ returns: {created_at: date}
315
+ })
302
316
 
303
- store.createRecord('profile').save().then(function(profile) {
304
- ok(profile.get('created_at') == date.toString())
305
- start();
317
+ store.createRecord('profile').save().then(function(profile) {
318
+ ok(profile.get('created_at') == date.toString())
319
+ start();
320
+ });
306
321
  });
307
322
  });
308
323
 
309
324
  asyncTest("#handleCreate returns camelCase attributes", function() {
310
- var customDescription = "special description"
325
+ Em.run(function() {
326
+ var customDescription = "special description"
311
327
 
312
- testHelper.handleCreate('profile', {
313
- returns: {camel_case_description: customDescription}
314
- })
328
+ testHelper.handleCreate('profile', {
329
+ returns: {camel_case_description: customDescription}
330
+ })
315
331
 
316
- store.createRecord('profile', {
317
- camel_case_description: 'description'
318
- }).save().then(function(profile) {
319
- ok(profile.get('camelCaseDescription') == customDescription)
320
- start();
332
+ store.createRecord('profile', {
333
+ camel_case_description: 'description'
334
+ }).save().then(function(profile) {
335
+ ok(profile.get('camelCaseDescription') == customDescription)
336
+ start();
337
+ });
321
338
  });
322
339
  });
323
340
 
324
341
  asyncTest("#handleCreate match belongsTo association", function() {
325
- var company = make('company')
326
- testHelper.handleCreate('profile', {match:{ company: company}})
342
+ Em.run(function() {
343
+ var company = make('company')
344
+ testHelper.handleCreate('profile', {match:{ company: company}})
327
345
 
328
- store.createRecord('profile', {company: company}).save().then(function(profile) {
329
- ok(profile.get('company') == company)
330
- start();
346
+ store.createRecord('profile', {company: company}).save().then(function(profile) {
347
+ ok(profile.get('company') == company)
348
+ start();
349
+ });
331
350
  });
332
351
  });
333
352
 
334
353
  asyncTest("#handleCreate match belongsTo polymorphic association", function() {
335
- var group = make('group')
336
- testHelper.handleCreate('profile', {match:{ group: group}})
354
+ Em.run(function() {
355
+ var group = make('group')
356
+ testHelper.handleCreate('profile', {match:{ group: group}})
337
357
 
338
- store.createRecord('profile', {group: group}).save().then(function(profile) {
339
- ok(profile.get('group') == group)
340
- start();
358
+ store.createRecord('profile', {group: group}).save().then(function(profile) {
359
+ ok(profile.get('group') == group)
360
+ start();
361
+ });
341
362
  });
342
363
  });
343
364
 
344
365
 
345
366
  asyncTest("#handleCreate match attributes and return attributes", function() {
346
- var date = new Date()
347
- var customDescription = "special description"
348
- var company = make('company')
349
- var group = make('big_group')
350
-
351
- testHelper.handleCreate('profile', {
352
- match: {description: customDescription, company: company, group: group},
353
- returns: {created_at: new Date()}
354
- })
355
-
356
- store.createRecord('profile', {
357
- description: customDescription, company: company, group: group
358
- }).save().then(function(profile) {
359
- start();
360
- ok(profile.get('created_at') == date.toString())
361
- ok(profile.get('group') == group)
362
- ok(profile.get('company') == company)
363
- ok(profile.get('description') == customDescription)
367
+ Em.run(function() {
368
+ var date = new Date()
369
+ var customDescription = "special description"
370
+ var company = make('company')
371
+ var group = make('big_group')
372
+
373
+ testHelper.handleCreate('profile', {
374
+ match: {description: customDescription, company: company, group: group},
375
+ returns: {created_at: new Date()}
376
+ })
377
+
378
+ store.createRecord('profile', {
379
+ description: customDescription, company: company, group: group
380
+ }).save().then(function(profile) {
381
+ start();
382
+ ok(profile.get('created_at') == date.toString())
383
+ ok(profile.get('group') == group)
384
+ ok(profile.get('company') == company)
385
+ ok(profile.get('description') == customDescription)
386
+ });
364
387
  });
365
388
  });
366
389
 
367
390
 
368
391
  asyncTest("#handleCreate failure", function() {
369
- testHelper.handleCreate('profile', { succeed: false } )
392
+ Em.run(function() {
393
+ testHelper.handleCreate('profile', { succeed: false } )
370
394
 
371
- store.createRecord('profile').save()
372
- .then(
373
- function() {},
374
- function() {
375
- ok(true)
376
- start();
377
- }
378
- )
395
+ store.createRecord('profile').save()
396
+ .then(
397
+ function() {},
398
+ function() {
399
+ ok(true)
400
+ start();
401
+ }
402
+ )
403
+ });
379
404
  });
380
405
 
381
406
 
382
407
  asyncTest("#handleCreate match but still fail", function() {
383
- var description = "special description"
408
+ Em.run(function() {
409
+ var description = "special description"
384
410
 
385
- testHelper.handleCreate('profile', {
386
- match: {description: description}, succeed: false
387
- })
411
+ testHelper.handleCreate('profile', {
412
+ match: {description: description}, succeed: false
413
+ })
388
414
 
389
- store.createRecord('profile', {description: description}).save()
390
- .then(
391
- function() {},
392
- function() {
393
- ok(true)
394
- start();
395
- }
396
- )
415
+ store.createRecord('profile', {description: description}).save()
416
+ .then(
417
+ function() {},
418
+ function() {
419
+ ok(true)
420
+ start();
421
+ }
422
+ )
423
+ });
397
424
  });
398
425
 
399
426
  /////// handleCreate //////////
400
427
  /////// with chaining methods ///////////////////
401
428
 
402
429
  asyncTest("#handleCreate match some attributes with match method", function() {
403
- var customDescription = "special description"
404
- var date = new Date();
405
-
406
- testHelper.handleCreate('profile').match({description: customDescription});
407
-
408
- store.createRecord('profile', {
409
- description: customDescription, created_at: date
410
- }).save().then(function(profile) {
411
- ok(profile instanceof Profile)
412
- ok(profile.id == 1)
413
- ok(profile.get('description') == customDescription)
414
- start();
430
+ Em.run(function() {
431
+ var customDescription = "special description"
432
+ var date = new Date();
433
+
434
+ testHelper.handleCreate('profile').match({description: customDescription});
435
+
436
+ store.createRecord('profile', {
437
+ description: customDescription, created_at: date
438
+ }).save().then(function(profile) {
439
+ ok(profile instanceof Profile)
440
+ ok(profile.id == 1)
441
+ ok(profile.get('description') == customDescription)
442
+ start();
443
+ });
415
444
  });
416
445
  });
417
446
 
418
447
  asyncTest("#handleCreate match all attributes with match method", function() {
419
- var customDescription = "special description"
420
- var date = new Date();
421
-
422
- testHelper.handleCreate('profile').match({description: customDescription, created_at: date});
423
-
424
- store.createRecord('profile', {
425
- description: customDescription, created_at: date
426
- }).save().then(function(profile) {
427
- ok(profile instanceof Profile)
428
- ok(profile.id == 1)
429
- ok(profile.get('description') == customDescription)
430
- ok(profile.get('created_at') == date.toString())
431
- start();
448
+ Em.run(function() {
449
+ var customDescription = "special description"
450
+ var date = new Date();
451
+
452
+ testHelper.handleCreate('profile').match({description: customDescription, created_at: date});
453
+
454
+ store.createRecord('profile', {
455
+ description: customDescription, created_at: date
456
+ }).save().then(function(profile) {
457
+ ok(profile instanceof Profile)
458
+ ok(profile.id == 1)
459
+ ok(profile.get('description') == customDescription)
460
+ ok(profile.get('created_at') == date.toString())
461
+ start();
462
+ });
432
463
  });
433
464
  });
434
465
 
435
466
  asyncTest("#handleCreate match belongsTo association with match method", function() {
436
- var company = make('company')
437
- testHelper.handleCreate('profile').match({company: company})
467
+ Em.run(function() {
468
+ var company = make('company')
438
469
 
439
- store.createRecord('profile', {company: company}).save().then(function(profile) {
440
- ok(profile.get('company') == company)
441
- start();
470
+ testHelper.handleCreate('profile').match({company: company})
471
+
472
+ store.createRecord('profile', {company: company}).save().then(function(profile) {
473
+ ok(profile.get('company') == company)
474
+ start();
475
+ });
442
476
  });
443
477
  });
444
478
 
445
479
  asyncTest("#handleCreate match belongsTo polymorphic association with match method", function() {
446
- var group = make('group')
447
- testHelper.handleCreate('profile').match({group: group})
480
+ Em.run(function() {
481
+ var group = make('group')
482
+ testHelper.handleCreate('profile').match({group: group})
448
483
 
449
- store.createRecord('profile', {group: group}).save().then(function(profile) {
450
- ok(profile.get('group') == group)
451
- start();
484
+ store.createRecord('profile', {group: group}).save().then(function(profile) {
485
+ ok(profile.get('group') == group)
486
+ start();
487
+ });
452
488
  });
453
489
  });
454
490
 
455
491
 
456
492
 
457
493
  asyncTest("#handleCreate returns attributes with andReturns method", function() {
458
- var date = new Date()
494
+ Em.run(function() {
495
+ var date = new Date()
459
496
 
460
- testHelper.handleCreate('profile').andReturn({created_at: date});
497
+ testHelper.handleCreate('profile').andReturn({created_at: date});
461
498
 
462
- store.createRecord('profile').save().then(function(profile) {
463
- ok(profile.get('created_at') == date.toString())
464
- start();
499
+ store.createRecord('profile').save().then(function(profile) {
500
+ ok(profile.get('created_at') == date.toString())
501
+ start();
502
+ });
465
503
  });
466
504
  });
467
505
 
468
506
  asyncTest("#handleCreate match attributes and return attributes with match and andReturn methods", function() {
469
- var date = new Date()
470
- var customDescription = "special description"
471
- var company = make('company')
472
- var group = make('big_group')
473
-
474
- testHelper.handleCreate('profile')
475
- .match({description: customDescription, company: company, group: group})
476
- .andReturn({created_at: new Date()})
477
-
478
- store.createRecord('profile', {
479
- description: customDescription, company: company, group: group
480
- }).save().then(function(profile) {
481
- start();
482
- ok(profile.get('created_at') == date.toString())
483
- ok(profile.get('group') == group)
484
- ok(profile.get('company') == company)
485
- ok(profile.get('description') == customDescription)
507
+ Em.run(function() {
508
+ var date = new Date()
509
+ var customDescription = "special description"
510
+ var company = make('company')
511
+ var group = make('big_group')
512
+
513
+ testHelper.handleCreate('profile')
514
+ .match({description: customDescription, company: company, group: group})
515
+ .andReturn({created_at: new Date()})
516
+
517
+ store.createRecord('profile', {
518
+ description: customDescription, company: company, group: group
519
+ }).save().then(function(profile) {
520
+ start();
521
+ ok(profile.get('created_at') == date.toString())
522
+ ok(profile.get('group') == group)
523
+ ok(profile.get('company') == company)
524
+ ok(profile.get('description') == customDescription)
525
+ });
486
526
  });
487
527
  });
488
528
 
489
529
 
490
530
  asyncTest("#handleCreate failure with andFail method", function() {
491
- testHelper.handleCreate('profile').andFail();
531
+ Em.run(function() {
532
+ testHelper.handleCreate('profile').andFail();
492
533
 
493
- store.createRecord('profile').save()
494
- .then(
495
- function() {},
496
- function() {
497
- ok(true)
498
- start();
499
- }
500
- )
534
+ store.createRecord('profile').save()
535
+ .then(
536
+ function() {},
537
+ function() {
538
+ ok(true)
539
+ start();
540
+ }
541
+ )
542
+ });
501
543
  });
502
544
 
503
545
 
504
546
  asyncTest("#handleCreate match but still fail with chaining methods", function() {
505
- var description = "special description"
547
+ Em.run(function() {
548
+ var description = "special description"
506
549
 
507
- testHelper.handleCreate('profile').match({description: description}).andFail();
550
+ testHelper.handleCreate('profile').match({description: description}).andFail();
508
551
 
509
- store.createRecord('profile', {description: description}).save()
510
- .then(
511
- function() {},
512
- function() {
513
- ok(true)
514
- start();
515
- }
516
- )
552
+ store.createRecord('profile', {description: description}).save()
553
+ .then(
554
+ function() {},
555
+ function() {
556
+ ok(true)
557
+ start();
558
+ }
559
+ )
560
+ });
517
561
  });
518
562
 
519
563
 
@@ -584,78 +628,91 @@ test("#handleUpdate with incorrect parameters", function(assert) {
584
628
  });
585
629
 
586
630
  asyncTest("#handleUpdate the with modelType and id", function() {
587
- var profile = make('profile');
588
- testHelper.handleUpdate('profile', profile.id);
631
+ Em.run(function() {
632
+ var profile = make('profile');
633
+ testHelper.handleUpdate('profile', profile.id);
589
634
 
590
- profile.set('description','new desc');
591
- profile.save().then(function(profile) {
592
- ok(profile.get('description') == 'new desc');
593
- start();
635
+ profile.set('description','new desc');
636
+ profile.save().then(function(profile) {
637
+ ok(profile.get('description') == 'new desc');
638
+ start();
639
+ });
594
640
  });
595
641
  });
596
642
 
597
643
 
598
644
  asyncTest("#handleUpdate the with model", function() {
599
- var profile = make('profile');
600
- testHelper.handleUpdate(profile, true, {e:1});
645
+ Em.run(function() {
646
+ var profile = make('profile');
647
+ testHelper.handleUpdate(profile, true, {e:1});
601
648
 
602
- profile.set('description','new desc');
603
- profile.save().then(function(profile) {
604
- ok(profile.get('description') == 'new desc');
605
- start();
649
+ profile.set('description','new desc');
650
+ profile.save().then(function(profile) {
651
+ ok(profile.get('description') == 'new desc');
652
+ start();
653
+ });
606
654
  });
607
655
  });
608
656
 
609
657
  asyncTest("#handleUpdate the with modelType and id that fails", function() {
610
- var profile = make('profile');
611
- testHelper.handleUpdate('profile', profile.id, false);
612
-
613
- profile.set('description','new desc');
614
- profile.save().then(
615
- function() {},
616
- function() {
617
- ok(true)
618
- start();
619
- }
620
- )
621
- });
622
-
623
- asyncTest("#handleUpdate with model that fails", function() {
624
- var profile = make('profile');
625
- testHelper.handleUpdate(profile, false);
658
+ Em.run(function() {
659
+ var profile = make('profile');
660
+ testHelper.handleUpdate('profile', profile.id, false);
626
661
 
627
- profile.set('description','new desc');
628
- profile.save().then(
662
+ profile.set('description','new desc');
663
+ profile.save().then(
629
664
  function() {},
630
665
  function() {
631
666
  ok(true)
632
667
  start();
633
668
  }
634
669
  )
670
+ });
671
+ });
672
+
673
+ asyncTest("#handleUpdate with model that fails", function() {
674
+ Em.run(function() {
675
+ var profile = make('profile');
676
+
677
+ testHelper.handleUpdate(profile, false);
678
+
679
+ profile.set('description','new desc');
680
+ profile.save().then(
681
+ function() {},
682
+ function() {
683
+ ok(true)
684
+ start();
685
+ }
686
+ )
687
+ });
635
688
  });
636
689
 
637
690
 
638
691
  /////// handleDelete //////////
639
692
 
640
693
  asyncTest("#handleDelete the basic", function() {
641
- var profile = make('profile');
642
- testHelper.handleDelete('profile', profile.id);
694
+ Em.run(function() {
695
+ var profile = make('profile');
696
+ testHelper.handleDelete('profile', profile.id);
643
697
 
644
- profile.destroyRecord().then(function() {
645
- equal(store.all('profile').get('content.length'), 0);
646
- start();
698
+ profile.destroyRecord().then(function() {
699
+ equal(store.all('profile').get('content.length'), 0);
700
+ start();
701
+ });
647
702
  });
648
703
  });
649
704
 
650
705
  asyncTest("#handleDelete failure case", function() {
651
- var profile = make('profile');
652
- testHelper.handleDelete('profile', profile.id, false);
706
+ Em.run(function() {
707
+ var profile = make('profile');
708
+ testHelper.handleDelete('profile', profile.id, false);
653
709
 
654
- profile.destroyRecord().then(
655
- function() {},
656
- function() {
657
- ok(true);
658
- start();
659
- }
660
- );
710
+ profile.destroyRecord().then(
711
+ function() {},
712
+ function() {
713
+ ok(true);
714
+ start();
715
+ }
716
+ );
717
+ });
661
718
  });
@@ -51,7 +51,9 @@ test("#resetModels clears the store of models, clears the FIXTURES arrays for ea
51
51
  equal(store.all('user').get('length'), 1);
52
52
  equal(store.all('project').get('length'), 1);
53
53
 
54
- FactoryGuy.resetModels(store);
54
+ Em.run(function() {
55
+ FactoryGuy.resetModels(store);
56
+ });
55
57
 
56
58
  equal(User.FIXTURES.length, 0);
57
59
  equal(Project.FIXTURES.length, 0);
data/tests/index.html CHANGED
@@ -24,20 +24,18 @@
24
24
  <script src='../tests/test_setup.js'></script>
25
25
  <script src='../tests/support/test_helper.js'></script>
26
26
 
27
-
28
-
29
27
  </head>
30
28
  <body>
31
29
  <div id="qunit"></div> <!-- QUnit fills this with results, etc -->
32
30
  <script src='active_model_adapter_factory_test.js'></script>
33
31
  <script src='rest_adapter_factory_test.js'></script>
34
- <script src='fixture_adapter_factory_test.js'></script>
32
+ <!--<script src='fixture_adapter_factory_test.js'></script>-->
35
33
  <script src='store_test.js'></script>
36
34
  <script src='factory_guy_test.js'></script>
37
35
  <script src='factory_guy_test_mixin_test.js'></script>
38
36
  <div id='qunit-fixture'>
39
37
 
40
- <!-- any HTML you want to be present in each test (will be reset for each test) -->
38
+ <!-- any HTML you want to be present in each test (will be reset for each test) -->
41
39
 
42
40
  </div>
43
41
  </body>
@@ -13,24 +13,26 @@ module('FactoryGuy with DS.RESTAdapter', {
13
13
 
14
14
 
15
15
  test("#resetModels clears the store of models, and resets the model definition", function() {
16
- var project = make('project');
17
- var user = make('user', {projects: [project]});
16
+ Em.run(function() {
17
+ var project = make('project');
18
+ var user = make('user', {projects: [project]});
18
19
 
19
- for (model in FactoryGuy.modelDefinitions) {
20
- var definition = FactoryGuy.modelDefinitions[model];
21
- sinon.spy(definition, 'reset');
22
- }
20
+ for (model in FactoryGuy.modelDefinitions) {
21
+ var definition = FactoryGuy.modelDefinitions[model];
22
+ sinon.spy(definition, 'reset');
23
+ }
23
24
 
24
- FactoryGuy.resetModels(store);
25
+ FactoryGuy.resetModels(store);
25
26
 
26
- equal(store.all('user').get('content.length'), 0)
27
- equal(store.all('project').get('content.length'), 0)
27
+ equal(store.all('user').get('content.length'), 0)
28
+ equal(store.all('project').get('content.length'), 0)
28
29
 
29
- for (model in FactoryGuy.modelDefinitions) {
30
- var definition = FactoryGuy.modelDefinitions[model];
31
- ok(definition.reset.calledOnce);
32
- definition.reset.restore();
33
- }
30
+ for (model in FactoryGuy.modelDefinitions) {
31
+ var definition = FactoryGuy.modelDefinitions[model];
32
+ ok(definition.reset.calledOnce);
33
+ definition.reset.restore();
34
+ }
35
+ });
34
36
  });
35
37
 
36
38
 
data/tests/store_test.js CHANGED
@@ -52,18 +52,20 @@ testFixtureEquality = function(models, json, num){
52
52
  }
53
53
 
54
54
  asyncTest("no root", function() {
55
- var userJson = {
56
- id: '1',
57
- name: 'monkey'
58
- };
59
-
60
- store.pushPayload('user', userJson);
61
- store.find('user').then(function(users){
62
- equal(users.get('length'), 1, 'Expected one user in the data store');
63
-
64
- equal(users.get('firstObject.id'), userJson.id);
65
- equal(users.get('firstObject.name'), userJson.name);
66
- start();
55
+ Em.run(function() {
56
+ var userJson = {
57
+ id: '1',
58
+ name: 'monkey'
59
+ };
60
+
61
+ store.pushPayload('user', userJson);
62
+ store.find('user').then(function(users){
63
+ equal(users.get('length'), 1, 'Expected one user in the data store');
64
+
65
+ equal(users.get('firstObject.id'), userJson.id);
66
+ equal(users.get('firstObject.name'), userJson.name);
67
+ start();
68
+ });
67
69
  });
68
70
  });
69
71
 
@@ -94,86 +96,92 @@ asyncTest("no root replace data", function(){
94
96
  });
95
97
 
96
98
  asyncTest("single root", function() {
97
- var userJson = {
98
- users: [{ id:'1', name:'monkey' }, { id:'2', name:'banana' }]
99
- };
99
+ Em.run(function() {
100
+ var userJson = {
101
+ users: [{ id:'1', name:'monkey' }, { id:'2', name:'banana' }]
102
+ };
100
103
 
101
- store.pushPayload(userJson);
102
- store.find('user').then(function(users) {
104
+ store.pushPayload(userJson);
105
+ store.find('user').then(function(users) {
103
106
 
104
- testFixtureEquality(users, userJson['users'], 2);
107
+ testFixtureEquality(users, userJson['users'], 2);
105
108
 
106
- users.forEach(function(user) {
107
- var u = userJson['users'].findBy('id', user.get('id'));
108
- equal(user.get('name'), u.name, 'Got unexpected name ' + user.get('name'));
109
- });
109
+ users.forEach(function(user) {
110
+ var u = userJson['users'].findBy('id', user.get('id'));
111
+ equal(user.get('name'), u.name, 'Got unexpected name ' + user.get('name'));
112
+ });
110
113
 
111
- start();
114
+ start();
115
+ });
112
116
  });
113
117
  });
114
118
 
115
119
  asyncTest("multiple roots", function() {
116
- var json = {
117
- companies: [{ id: '1', name: 'Google', projects: ['1', '2'] }],
118
- projects: [
119
- { id:'1', title: 'Docs', user: '1' },
120
- { id:'2', title: 'Gmail' }
121
- ],
122
- users: [{ id: '1', name: 'monkey', projects: ['1'] }],
123
- profiles: [
124
- { id: '1', created_at: new Date(), description: 'banana' },
125
- { id: '2', created_at: new Date(), description: 'monkey' }
126
- ],
127
- hats: [
128
- { id: '2', type: 'Trilby' }
129
- ],
130
- };
120
+ Em.run(function() {
121
+ var json = {
122
+ companies: [{ id: '1', name: 'Google', projects: ['1', '2'] }],
123
+ projects: [
124
+ { id:'1', title: 'Docs', user: '1' },
125
+ { id:'2', title: 'Gmail' }
126
+ ],
127
+ users: [{ id: '1', name: 'monkey', projects: ['1'] }],
128
+ profiles: [
129
+ { id: '1', created_at: new Date(), description: 'banana' },
130
+ { id: '2', created_at: new Date(), description: 'monkey' }
131
+ ],
132
+ hats: [
133
+ { id: '2', type: 'Trilby' }
134
+ ],
135
+ };
131
136
 
132
- store.pushPayload(json);
133
- Ember.RSVP.Promise.all([
134
- store.find('company'), store.find('project'),
135
- store.find('user'), store.find('profile'), store.find('hat')
136
- ]).then(function(data) {
137
- var companies = data[0],
138
- projects = data[1],
139
- users = data[2],
140
- profiles = data[3],
141
- hats = data[4];
142
-
143
- testFixtureEquality(companies, json['companies'], 1);
144
- testFixtureEquality(projects, json['projects'], 2);
145
- testFixtureEquality(users, json['users'], 1);
146
- testFixtureEquality(profiles, json['profiles'], 2);
147
- testFixtureEquality(hats, json['hats'], 1);
148
-
149
- start();
137
+ store.pushPayload(json);
138
+ Ember.RSVP.Promise.all([
139
+ store.find('company'), store.find('project'),
140
+ store.find('user'), store.find('profile'), store.find('hat')
141
+ ]).then(function(data) {
142
+ var companies = data[0],
143
+ projects = data[1],
144
+ users = data[2],
145
+ profiles = data[3],
146
+ hats = data[4];
147
+
148
+ testFixtureEquality(companies, json['companies'], 1);
149
+ testFixtureEquality(projects, json['projects'], 2);
150
+ testFixtureEquality(users, json['users'], 1);
151
+ testFixtureEquality(profiles, json['profiles'], 2);
152
+ testFixtureEquality(hats, json['hats'], 1);
153
+
154
+ start();
155
+ });
150
156
  });
151
157
  });
152
158
 
153
159
  asyncTest("multiple roots with type specified", function() {
154
- var json = {
155
- companies: [{ id: '1', name: 'Google', projects: ['1', '2'] }],
156
- projects: [
157
- { id:'1', title: 'Docs', user: '1' },
158
- { id:'2', title: 'Gmail' }
159
- ],
160
- users: [{ id: '1', name: 'monkey', projects: ['1'] }],
161
- }
162
-
163
- store.pushPayload('company', json);
164
-
165
- Ember.RSVP.Promise.all([
166
- store.find('company'), store.find('project'), store.find('user')
167
- ]).then(function(data) {
168
- var companies = data[0],
169
- projects = data[1],
170
- users = data[2];
171
-
172
- testFixtureEquality(companies, json['companies'], 1);
173
- testFixtureEquality(projects, json['projects'], 2);
174
- testFixtureEquality(users, json['users'], 1);
175
-
176
- start();
160
+ Em.run(function() {
161
+ var json = {
162
+ companies: [{ id: '1', name: 'Google', projects: ['1', '2'] }],
163
+ projects: [
164
+ { id:'1', title: 'Docs', user: '1' },
165
+ { id:'2', title: 'Gmail' }
166
+ ],
167
+ users: [{ id: '1', name: 'monkey', projects: ['1'] }],
168
+ }
169
+
170
+ store.pushPayload('company', json);
171
+
172
+ Ember.RSVP.Promise.all([
173
+ store.find('company'), store.find('project'), store.find('user')
174
+ ]).then(function(data) {
175
+ var companies = data[0],
176
+ projects = data[1],
177
+ users = data[2];
178
+
179
+ testFixtureEquality(companies, json['companies'], 1);
180
+ testFixtureEquality(projects, json['projects'], 2);
181
+ testFixtureEquality(users, json['users'], 1);
182
+
183
+ start();
184
+ });
177
185
  });
178
186
  });
179
187
 
@@ -1,7 +1,7 @@
1
1
  Group = DS.Model.extend({
2
2
  type: DS.attr('string', {defaultValue: 'Group'}),
3
3
  name: DS.attr('string'),
4
- versions: DS.hasMany('group'),
4
+ versions: DS.hasMany('group', {inverse: null}),
5
5
  profiles: DS.hasMany('profile')
6
6
  })
7
7
 
@@ -85,6 +85,8 @@ TestHelper = Ember.Object.createWithMixins(FactoryGuy.testMixin,{
85
85
  container.register('transform:object', ObjectTransform);
86
86
  container.injection('serializer', 'store', 'store:main');
87
87
 
88
+ Ember.setupForTesting()
89
+
88
90
  env.store = container.lookup('store:main');
89
91
  env.adapter = env.store.get('defaultAdapter');
90
92
 
data/tests/test_setup.js CHANGED
@@ -15,7 +15,7 @@ SmallCompany = Company.extend({
15
15
  Group = DS.Model.extend({
16
16
  type: DS.attr('string', {defaultValue: 'Group'}),
17
17
  name: DS.attr('string'),
18
- versions: DS.hasMany('group'),
18
+ versions: DS.hasMany('group', {inverse: null}),
19
19
  profiles: DS.hasMany('profile')
20
20
  })
21
21
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ember-data-factory-guy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.8
4
+ version: 0.9.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Sudol
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-03 00:00:00.000000000 Z
12
+ date: 2015-02-20 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Easily create Fixtures for Ember Data
15
15
  email: